MenuExtended is undergoing major refactoring; the below may not entirely be true as I haven’t updated that yet!
MenuExtended is actually a simple alternative to Wayfinder, the main menu builder every MODX Developer has worked with.
The reason this is called MenuExtended is cause there is extended control over what is displayed in the menu. It’s probably also faster than Wayfinder in a lot of cases (tho I haven’t run any real tests), but it doesn’t support all options Wayfinder does.
It lacks multi-context support (tho it may just work.. simply haven’t tested so can’t promise), more than one level deep nesting (at this point) and the amount of configuration Wayfinder offers you.
The reason I developed it for a client was a main navigation that didn’t match the resource tree. Both are proper for their contexts, but they simply don’t work together and would require at least three Wayfinder/getResources calls to work properly.
This is the desired menu structure in that specific case:
- Shop Category 1
- Another shop Category
- Category tres
- Blog
- About Us
- About the Company
- The Team
- Terms & Conditions
The problem is that the site structure totally didn’t match that:
- Home
- Shop (ID 2)
- Shop Category 1
- Another shop Category
- Category tres
- Blog (ID 3)
- 2011 (auto generated)
- 2010 (auto generated)
- About Us (ID 4)
- About the Company
- The Team
- Terms & Conditions
So we would need to show:
1. The children of the Shop (ID 2) as level 1 items.
2. The “Blog” (ID 3) container – but not the children.
3. The “About Us” (ID 4) container and its children.
Good luck with that, Wayfinder!
So that’s what MenuExtended does – it allows you to specify exactly what to include: the parent you specify, just its children or both.
Here’s how I did it using my custom menu snippet:
[[MenuExtended? &resources=`2+,3*,4`]]The key there is the use of tokens after the resources. There’s three options:
1. No token: show this resource and all its (first-level) children. We’re using this for ID 4 (About Us).
2. An asterix (*): indicates we only want the parent, in this case that’s for the blog (ID 3).
3. A + sign: indicates we only want the children, we’re using that for the shop categories (parent ID 2).
- &resources: comma separated list of resources/parents, optionally with a token (see above example) to denote how to treat it. (2,3,4*)
- &depth: depth to look up resources. MenuExtended only supports TWO levels (parent, child) right now. You can increase the depth but it’ll do nothing (1)
- &hideUnpublished: [1|0] to hide unpublished resources from the output (1)
- &hideHidden: [1|0] to hide resources (marked as hidden from menu) from the output (0)
- &hideDeleted: [1|0] to hide deleted resources from the output (1)
- &fields: comma separated list of fields to include in the output. Resource fields ONLY. Default: id,context_key,pagetitle,menutitle,longtitle
- &rowTpl: chunkname to use as row tpl. Include placeholders like
[[+pagetitle]]
and[[~[[+id]]]]
. Use[[+wrapper]]
for subresources. - &innerTpl: chunk to use as inner tpl. Use [[+wrapper]] placeholder.
- &childTpl: optional chunk to use instead of the rowTpl when we’re dealing with a subresource.
- &outerTpl: optional outer chunk. Use [[+wrapper]] again.
- &childSeparator: string used to separate child resources. Defaults to a linebreak.
- &rowSeparator: string used to separate rowTpls. Defaults to a linebreak.
- &classLast: class to use for last item. Defaults to “last”.
- &classActive: class to use for active item. Defaults to “active”.
- &classFirst: class to use for first item. Defaults to “first”
- &debug: [1|0] enable debug messages. Defaults to 0.