It's good to understand the high-level design paradigm and I appreciate the thought that has gone into it. It makes sense. So, the menu membership would be a MultipleChoiceField configured through a setting? No need then, for a many-to-many relationship to another table. The menu templates would define any special behavior like drop-down level or group-based visibility and users could build their own.
Would it be possible to have an admin view that is menu-centric, meaning not having to go edit every page to assign them to a new menu. Could be an action on pages view.
I've pushed up a first version of the new "in_menus" field for pages:Here's the gist of it:The "in_navigation" and "in_footer" fields are gone and replace with a new field "in_menus", which contains a comma-separated list of menu IDs that the page belongs to. The menu IDs are defined in the setting PAGE_MENU_TEMPLATES which looks like this:PAGE_MENU_TEMPLATES = ((1, "Top nav", "pages/menus/dropdown.html"),(2, "Left tree nav", "pages/menus/tree.html"),(3, "Footer", "pages/menus/footer.html"),)So you can define the exact menu templates available in your project.In the menu templates, page objects now have an attribute "in_menu", to use in place of the removed fields, and the variables "page_branch_in_footer" and "page_branch_in_navigation" are replaced with "page_branch_in_menu" (the old attributes and variables remain for now as best as possible, for backward compatibility with templates, take a look at the above commit to see their behaviour).
A couple of notes around the behaviour of this inside the "page_menu" template tag, which I'm going to add with some new docs for the way menus work:- Just as the old flags behaved, the new "in_menus" field doesn't actually filter pages from a menu - it's up to the menu template to check "page.in_menu" itself.- If a menu template isn't defined in PAGE_MENU_TEMPLATES, "page.in_menu" will always be True. Think of the "in_menus" field as controlling what menus the page *won't* be in, by unchecking them.- The default selection for the "in_menus" field with a new page is all menu templates, you can change the default selection by setting a sequence of menu IDs in the new PAGE_MENU_TEMPLATES_DEFAULT setting.On Sat, Jun 23, 2012 at 4:59 PM, Stephen McDonald <st...@jupo.org> wrote:
Just wanted to bring the conversation for this issue onto the mailing list:Currently pages have two flags for appearing in menus, "in navigation" and "in footer". This doesn't really make sense, as there maybe more than two types of menus on a site, and not necessarily a "footer" menu. The above issue talks about adding a new flag for the left-hand menu, but again the menus in use are going to be different for each site, and the flags should reflect this.I think the ideal setup would be one where we replaced the "in nav/footer" flags with a multi-select field, that allowed users to choose multiple selections from a list of menus, that the page is to appear in. The choices in that field would map directly to each menu implemented on the site, and then the checks could occur inside the actual page_menu template tag as to whether the pages being passed to the menu template should be available.The only thing I'm unsure about is how to populate the field with each type of menu available for selection. I'd love for it to not require any configuration or data. The menu templates are already conveniently bound to a single template directory (pages/menus) so we could simply provide a list of all the templates found in there for selection. The only problem with this is that there'd be more templates in the selection field than those that are actually in use. You might only implement a primary and a footer menu, but there'd be at least half a dozen to choose from.So I guess there could be a new setting that contained the names of the menu templates actually in use. Then the new field would be populated by it.Any thoughts on this change? Any gotchas? Any idea how to make it not require configuration?--
Stephen McDonald
http://jupo.org
--
Stephen McDonald
http://jupo.org
I've pushed up a first version of the new "in_menus" field for pages:Here's the gist of it:The "in_navigation" and "in_footer" fields are gone and replace with a new field "in_menus", which contains a comma-separated list of menu IDs that the page belongs to. The menu IDs are defined in the setting PAGE_MENU_TEMPLATES which looks like this:PAGE_MENU_TEMPLATES = ((1, "Top nav", "pages/menus/dropdown.html"),(2, "Left tree nav", "pages/menus/tree.html"),(3, "Footer", "pages/menus/footer.html"),)So you can define the exact menu templates available in your project.In the menu templates, page objects now have an attribute "in_menu", to use in place of the removed fields, and the variables "page_branch_in_footer" and "page_branch_in_navigation" are replaced with "page_branch_in_menu" (the old attributes and variables remain for now as best as possible, for backward compatibility with templates, take a look at the above commit to see their behaviour).A couple of notes around the behaviour of this inside the "page_menu" template tag, which I'm going to add with some new docs for the way menus work:
- Just as the old flags behaved, the new "in_menus" field doesn't actually filter pages from a menu - it's up to the menu template to check "page.in_menu" itself.- If a menu template isn't defined in PAGE_MENU_TEMPLATES, "page.in_menu" will always be True. Think of the "in_menus" field as controlling what menus the page *won't* be in, by unchecking them.- The default selection for the "in_menus" field with a new page is all menu templates, you can change the default selection by setting a sequence of menu IDs in the new PAGE_MENU_TEMPLATES_DEFAULT setting.On Sat, Jun 23, 2012 at 4:59 PM, Stephen McDonald <st...@jupo.org> wrote:
Just wanted to bring the conversation for this issue onto the mailing list:Currently pages have two flags for appearing in menus, "in navigation" and "in footer". This doesn't really make sense, as there maybe more than two types of menus on a site, and not necessarily a "footer" menu. The above issue talks about adding a new flag for the left-hand menu, but again the menus in use are going to be different for each site, and the flags should reflect this.I think the ideal setup would be one where we replaced the "in nav/footer" flags with a multi-select field, that allowed users to choose multiple selections from a list of menus, that the page is to appear in. The choices in that field would map directly to each menu implemented on the site, and then the checks could occur inside the actual page_menu template tag as to whether the pages being passed to the menu template should be available.The only thing I'm unsure about is how to populate the field with each type of menu available for selection. I'd love for it to not require any configuration or data. The menu templates are already conveniently bound to a single template directory (pages/menus) so we could simply provide a list of all the templates found in there for selection. The only problem with this is that there'd be more templates in the selection field than those that are actually in use. You might only implement a primary and a footer menu, but there'd be at least half a dozen to choose from.So I guess there could be a new setting that contained the names of the menu templates actually in use. Then the new field would be populated by it.Any thoughts on this change? Any gotchas? Any idea how to make it not require configuration?--
Stephen McDonald
http://jupo.org
--
Stephen McDonald
http://jupo.org