Skip to content
  1. Extras
  2. SeoFilter
  3. Snippets
  4. sfMenu

sfMenu

The most capable and powerful snippet. If you know pdoMenu, it will not feel complicated. The menu is built with a custom class; a lot is taken from pdoMenu, including almost all class support.

Внимание

Output differs from pdoMenu: the formed link is in [[+url]], and its label in [[+name]].

You can pass empty chunks and inspect the available placeholders.

The menu can be built taking into account the number of results on the page. For that you can use on-the-fly counting or values from the database (updated when products change or manually).

There are many parameters to control the menu; if you run into problems, contact modstore support and we will sort it out.

Main snippet parameters

ParameterDefaultDescription
&rulesComma-separated rule ids whose links should appear in the menu (prefix with minus to exclude)
&parentsComma-separated page ids that rules are attached to (minus to exclude)
&urlsOr separately, ids of generated links from the URL table (minus to exclude)
&fast1New fast menu mode; faster than the old one. Disabled if countChildren=1
&countChildren0Count resources (products) that will be on the page before building the menu; for large menus prefer DB-stored counts
&mincount0Minimum number of resources for a link to be included. In fast mode you can pass condition via where {"total:>=":1}
&sortcount0Sort by resource count; takes precedence over sortby. In fast mode you can also pass total in sortby
&relative0Experimental: rebuild menu from the current SEO page. When enabled, turns on double, nesting, hideSubMenus and turns off groupbyrule
&onlyrelative0Show menu only on SEO pages
&nesting0Virtual nesting of links inside links, building the tree more precisely
&hideSubMenus0Hide inactive menu branches; use together with nesting
&double0Duplicate links when nesting, since links can belong to several rules (multi-category)
&sortbycountSort; default by page view count
&sortdirDESCSort direction; default descending
&level0Maximum level to limit links. Level = number of fields the link is made of. 0 = no limit
&minlevel0Minimum level to limit links. 0 = no limit
&limit0Limit on how many links to select. With countChildren the number on the page may be lower (links are selected first, then some dropped by other conditions). In fast mode that does not happen
&offset0Offset to use with limit
&schemeScheme for building resource URLs. Can be "full", "abs", "http", "https", "-1" or empty
&contextBy default not set. Set if you have issues building URLs for links
&cache1Cache; on by default so links are not collected from DB every time. Counts are cached too
&cacheTime3600Cache TTL in seconds; default 1 hour
&groupbyrule0Group by rule (uses separate wrapper chunk in &tplGroup)
&groupsortlevelSort groups by number of fields in the rule
&groupdirASCGroup sort direction
&userank0Use rule priorities for sorting groups
&showHidden1Show hidden menu items. Turn off if you manually control which URL table entries appear in the menu
&count_whereExtra condition for resource count; used only when countChildren is on
&fastMode0Passed to pdoTools for chunk processing
&whereExtra JSON condition. You can filter by sfUrls, sfDictionary, sfUrlWord (e.g. limit menu to links related to "blue" color)
&toPlaceholderIf set, snippet saves all data to a placeholder with this name instead of outputting

Available chunks

Almost the same as pdoMenu chunks.

ChunkDescription
&tplStandard chunk for one link. Default: @INLINE <li{$classes}><a href="{$url}">{$name}{if $total?} ({$total}){/if}</a>{$wrapper}</li>
&tplOuterMenu wrapper. Default: @INLINE <ul{$classes}>{$wrapper}</ul>
&tplGroupWrapper when grouping by rule. Default: @INLINE <div><h4>{$name}</h4>{$wrapper}</div>
&tplHereCurrent document chunk
&tplInnerInner wrapper; if empty, tplOuter is used
&tplInnerRowInner row wrapper
&tplInnerHereCurrent inner row
&tplParentRowParent with children
&tplParentRowActiveActive parent with children
&tplParentRowHereCurrent parent with children

CSS class params

ParamDescription
&firstClassFirst item; default first
&hereClassActive item; default active
&innerClassInner links
&lastClassLast item; default last
&levelClassLevel class; e.g. level → level1, level2
&outerClassMenu wrapper
&parentClassParent/category
&rowClassRow class
&selfClassCurrent doc

Examples

  1. Fast mode, DB counts, sort by total, mincount 5:
modx
[[!sfMenu?
  &fast=`1`
  &sortby=`total`
  &sortdir=`DESC`
  &mincount=`5`
  &outerClass=`navigation`
  &innerClass=`inner`
  &levelClass=`level`
  &parentClass=`parent`
  &rowClass=`rows`
  &selfClass=`self`
]]
  1. Grouped, countChildren, exclude empty:
modx
[[!sfMenu?
  &countChildren=`1`
  &groupbyrule=`1`
  &sortby=`createdon`
  &sortdir=`ASC`
  &mincount=`1`
  &parents=`9`
  &tplGroup=`@INLINE <div class="col-sm-6"><h4>[[+name]] <small>[[+total]] links</small></h4>[[+wrapper]]</div>`
  &tplOuter=`@INLINE <ul[[+classes]]>[[+wrapper]]</ul>`
  &tpl=`@INLINE <li[[+classes]]><a href="[[+url]]">[[+name]]</a> <nobr><span>([[+total]])</span><small> - [[+count]] views</small></nobr>[[+wrapper]]</li>`
]]
  1. Nesting, mincount 2:
modx
[[!sfMenu?
  &countChildren=`1`
  &nesting=`1`
  &double=`0`
  &mincount=`2`
  &parents=`9`
]]