- Bug fix for
main_menu
template tag.
- The
use_specific
menu tag argument can now be one of 4 integer values, allowing for more fine-grained control over the use ofPage.specific
andPageQuerySet.specific()
when rendering menu tags (see README.md for further details). MainMenu
andFlatMenu
models now have ause_specific
field, to allow the defaultuse_specific
setting when rendering that menu to be changed via the admin area.MainMenu
andFlatMenu
models now have amax_levels
field, to allow the defaultmax_levels
setting when rendering that menu to be changed via the admin area.- When rendering a multi-level
MainMenu
or `FlatMenu, the model instances for those menus pre-fetch all of pages needed to generate the entire menu. The menu tags then request lists of child pages from menu instance as they are needed, reducing the need to hit the database at every single branch. - The
max_levels
,use_specific
,parent_page
andmenuitem_or_page
arguments passed to all template tags are now checked to ensure their values are valid, and if not, raise aValueError
with a helpful message to aid debugging. - Developers not using the
MenuPage
class or overriding any of wagtailPage
methods involved in URL generation can now enjoy better performance by choosing not to fetch any specific pages at all during rendering. Simply passuse_specific=USE_SPECIFIC_OFF
oruse_specific=0
to the tag, or update theuse_specific
field value on yourMainMenu
orFlatMenu
instances via the Wagtail admin area. - Dropped support for the
WAGTAILMENUS_DEFAULT_MAIN_MENU_MAX_LEVELS
andWAGTAILMENUS_DEFAULT_FLAT_MENU_MAX_LEVELS
settings. Default values are now set using themax_levels
field on the menu objects themselves. - Dropped support for the
WAGTAILMENUS_DEFAULT_MAIN_MENU_USE_SPECIFIC
andWAGTAILMENUS_DEFAULT_FLAT_MENU_USE_SPECFIC
settings. Default values are now set using theuse_specific
field on the menu objects themselves. - Eliminated a lot of code duplication in template tags by adding the
get_sub_menu_items_for_page
method, which is used bysub_menu
,section_menu
andchildren_menu
to do most of their work. - The default
show_multiple_levels
value for theflat_menu
tag is nowTrue
instead ofFalse
. The defaultmax_levels
field value forFlatMenu
instances is1
, which has the same effect. Only, the value can be changed via the admin area, and the changes will reflected immediately without having to explicitly addshow_multiple_levels=True
to the tag in templates. - The
has_submenu_items()
method onMenuPage
no longer accepts acheck_for_children
argument. - The
modify_submenu_items()
andhas_submenu_items()
methods on theMenuPage
model now both accept an optionalmenu_instance
value, so that menu_instance might be called to access pre-fetched page data without hitting the database. - Added the
WAGTAILMENUS_ADD_EDITOR_OVERRIDE_STYLES
setting to allow override styles to be disabled. - Other minor performance improvements.
- French translations added by François GUÉRIN (frague59)
- Improved confirmation messages when saving a menu in the admin area.
- Added a new test to submit the
MainMenu
edit form and check that it behaves as expected. - Added some styles to menu add/edit/copy views to improve the UI.
- Added a new
context_processor
to handle some of the logic that was previously being done in template tags. Django'sSimpleLazyObject
class is used to reduce the overhead as much as possible, only doing the work when the values are accessed by menu tags. - Added the
WAGTAILMENUS_GUESS_TREE_POSITION_FROM_PATH
setting to allow developers to disable the 'guess tree position from path' functionality that comes into play when serving custom views, where thebefore_serve_page
hook isn't activated, andwagtailmenu_params_helper()
inwagtail_hooks.py
doesn't get to add it's helpful values to the request/context. - Updated tox environment settings to run tests against wagtail==1.7, and
updated pinned wagtail version in
setup.py
to reflect compatibility. - Added unicode support for python 2.7 and added missing verbose_names to fields so that they can be translated (Alexey Krasnov & Andy Babic).
- Added support for a
WAGTAILMENUS_FLAT_MENUS_HANDLE_CHOICES
setting that, if set, will turn theCharField
used for FlatMenu.handle in add/edit/copy forms into aChoiceField
, with that setting as the available choices.
MenuPage.has_submenu_items()
is now only ever called ifcheck_for_children
is True inmenu_tags.prime_menu_items()
. This way, themax_levels
value supplied to the original menu tag is always respected, with no additional levels ever being rendered. Thecheck_for_chilren
value passed tohas_submenu_items()
is now always True. Since removing would add breaking changes, it will be removed in a later feature release.- Fixed a migration-related issue that was Django to create new migrations for the app.
- Fixed an issue where not all help text was marked for translation.
- Updated FlatMenu listing in CMS to only show site column and filters if menus are defined for more than one site.
- Added the
fall_back_to_default_site_menus
option to theflat_menu
tag, to allow flat menus defined for the default site to be used as fall-backs, in cases where the 'current' site doesn't have its own menus set up with the specified handle. - Added a custom ValidationError to FlatMenu's
clean()
method that better handles theunique_together
rule that applied tosite
andhandle
fields. - Added the ability to copy/duplicate existing FlatMenu objects between sites (or to the same site with a different handle) via Wagtail's admin area. The 'Copy' button appears in the listing for anyone with 'add' permission, and the view allows the user to make changes before anything is saved.
- Apply
active
classes to menu items that link to custom URLs (ifrequest.path
andlink_url
are exact matches). - Added a
handle
toMenuItem
model to provide a string which can be used to do specific matching of menu items in the template. (Tim Leguijt)
- Updated FlatMenu listing in CMS to include a column for
site
, a filter forhandle
, and a MenuItem count for each object. Also added default ordering, and output the handle value in atag to make it stand out.
- Made it easier to develop and debug wagtailmenus locally, by running it as a Django project. See CONTRIBUTING.md for instructions.
- Added a
get_for_site
class method to the FlatMenu model, to be consistent with the MainMenu model, and renamed thefor_site
method on MainMenu toget_for_site
for consistency.main_menu
andflat_menu
tags now make use of these. - Fixed an minor bug in the
prime_menu_items
method, where adepth
value was hard-coded, instead of utilising theSECTION_ROOT_LEVEL
setting.
- Added a
has_submenu_items()
method toMenuPage
model to complimentmodify_submenu_items()
in version 1.3. Allows for far better control and consistency when overridingmodify_submenu_items()
to add additional menu items for specific page types. - Added a
sub_menu_template
option tomain_menu
,section_menu
,flat_menu
andchildren_menu
that will be automatically picked up by thesub_menu
tag and used as the template (if notemplate
value is provided). - Added a
fetch_specific_pages
option to all template tags, that if True, will used PageQuerySet'sspecific()
method to return instances of the most specific page-type model as menu items, instead of just vanillaPage
objects. - Added settings to allow default
fetch_specific_pages
value to be altered for each individual menu tag. - If
fetch_specific_pages
is True,prime_menu_items
will call therelative_url
method on the specific page to determine a menu item'shref
value, meaning overrides to that method will be respected.
- Configured additional tox test environments for Wagtail>=1.6 with Django=1.9 and 1.10.
- Extended the 'section matching by path' functionality added in 1.3.0 to also identify a 'current page' if the found page matches the exact path.
- Added further tests for path matching.
- Reduced the number of unnecessary calls to
Page.specific
inmenu_tags.py
where possible.
- Added the ability for all menu tags to (attempt to) identify ancestor pages
and section root page by using components from the request path when serving
a custom URL (not routed via the page tree / served by
wagtail_serve
) - Added
modify_submenu_items()
method toMenuPage
model, which takes responsibility for modifying the initial menu_items list insection_menu
andsub_menu
tags. A DRYer approach, that is easier to extend/override to meet custom needs.
- Added PyPi version and coveralls test coverage badges to README
- Altered Travis CI test configuration to use tox, allowing for much better control over test environments
- Added tests for Python 3.4 and 3.5 to confirm compatibility
- Added CONTRIBUTORS.rst
- Added this changelog :)
- Added
WAGTAILMENUS_SECTION_ROOT_DEPTH
setting support, for more consistent identification of 'section root' pages