Blog Sections Open

Making Wayfinder Expand the Active Menu Branch

Why an accordion menu can fail to open the current branch when visitors arrive from internal links, and how to make Wayfinder output the right active classes.

An accordion menu may look correct when visitors click through the menu itself, but fail to open the active branch when they arrive from another internal link. In most cases the HTML structure is hard-coded while the Wayfinder class output is not being used consistently for parent items.

[!Wayfinder?
  &startId=`16`
  &onlyFolders=`1`
  &level=`2`
  &outerTpl=`tplMainMenuOuter`
  &rowTpl=`tplMainMenuRow`
  &parentRowTpl=`tplMainMenuParentRow`
  &checkAccess=`0`
!]

One common mistake is to hard-code the parent branch as always visible:

<ul style="display: block;">[+wf.wrapper+]</ul>

Let the active state come from [+wf.classes+] or a dedicated active-parent template instead.

Newer post

Fixing EvoGallery Image Paths Inside a Shopkeeper Cart

Why product thumbnails can disappear during Shopkeeper cart recalculation and how to keep EvoGallery image paths stable.

Older post

Passing Resource IDs Through a TV into Ditto

How to store a list of resource IDs in a TV and feed that list directly into Ditto for controlled cross-template output.