Blog Sections Open

Keeping Child Menus Expanded for the Active Branch in pdoMenu

A reusable pdoMenu pattern for keeping child lists expanded only when the current branch is active.

Expandable menus are easy to render and easy to style, but they often become awkward when you need one extra behavior: keep the current branch open while collapsing the rest. the underlying example solved that inside pdoMenu templates by tying submenu visibility to active branch state.

The useful part of this pattern is not the exact HTML. It is the idea that the inner wrapper can react to the same active markers you already expose in row templates.

Example idea

&tplParentRowHere=`@INLINE
<li class="active">...[[+wrapper]]</li>`

&tplInner=`@INLINE
<ul style="[[+ParentRowHere=`active`:then=`display: block`:else=`display: none`]]">[[+wrapper]]</ul>`

Why it works

  • The active parent row already marks the current branch.
  • The inner wrapper can read that state and switch between visible and collapsed output.
  • You keep one menu definition instead of maintaining separate trees for active and inactive branches.

In production projects, it is usually cleaner to move the final open/closed styling into CSS classes instead of inline styles. But as a logic pattern, this is a solid way to keep the current branch expanded without rewriting the whole navigation layer.

Newer post

Switching to Mobile Templates with OnWebPageInit and OnLoadDocumentObject

A practical two-plugin pattern for serving mobile templates in Evolution CMS while keeping cache behavior predictable.

Older post

Building Quantity-Based Cart Discounts with OnSHKcalcTotalPrice

How to implement progressive cart discounts in Shopkeeper using the OnSHKcalcTotalPrice event.