pdoMenu - Using different

Another point is, that there is no [[+id]] placeholder available in the tplOuter/tplInner templates.

Only these placeholders are set:
[[+wrapper]], [[+classes]], [[+classNames]], [[+classnames]], [[+level]]
[[+wf.wrapper]], [[+wf.classes]], [[+wf.classNames]], [[+wf.classnames]], [[+wf.level]]


So if you have to rely on the ID to determine the class of the <ul> in the template, then maybe move the <ul> to the &tpl template instead.

Here is an example: The tplOuter template contains only the [[+wrapper]] placeholder.

[[pdoMenu?
  &parents=`0`
  &level=`0`
  &tplOuter=`@INLINE {{+wrapper}}`
  &tpl=`navTpl`
]]

Chunk navTpl: (Assumes the page “Competition” has ID=3)

{set $parent_ids = $_modx->getParentIds($id)}
{if 3 in $parent_ids}
    *** child of competition ***
    {if $level == 1}
        <li class="competition-level1"><a href="{$link}" {$attributes}>{$menutitle}</a>
        {if $wrapper?}
            <ul class="competition-level1">{$wrapper}</ul>
        {/if}
        </li>
    {elseif $level == 2}
        <li class="competition-level2"><a href="{$link}" {$attributes}>{$menutitle}</a>
        {if $wrapper?}
            <ul class="competition-level2">{$wrapper}</ul>
        {/if}
        </li>
    {elseif $level == 3}
        <li class="competition-level3"><a href="{$link}" {$attributes}>{$menutitle}</a>
        {if $wrapper?}
            <ul class="competition-level3">{$wrapper}</ul>
        {/if}
        </li>
    {else}
        <li class="competition-level4"><a href="{$link}" {$attributes}>{$menutitle}</a>
        {if $wrapper?}
            <ul class="competition-level4">{$wrapper}</ul>
        {/if}
        </li>
    {/if}
{elseif $id == 3}
    *** COMPETITION ***
    <li class="competition"><a href="{$link}" {$attributes}>{$menutitle}</a>
    {if $wrapper?}
        <ul class="competition">{$wrapper}</ul>
    {/if}
    </li>
{else}
    +++ other branch +++
    {if $level == 1}
        <li class="level1"><a href="{$link}" {$attributes}>{$menutitle}</a>
        {if $wrapper?}
            <ul class="level1">{$wrapper}</ul>
        {/if}
        </li>
    {elseif $level == 2}
        <li class="level2"><a href="{$link}" {$attributes}>{$menutitle}</a>
        {if $wrapper?}
            <ul class="level2">{$wrapper}</ul>
        {/if}
        </li>
    {else}
        <li class="level3"><a href="{$link}" {$attributes}>{$menutitle}</a>
        {if $wrapper?}
            <ul class="level3">{$wrapper}</ul>
        {/if}
        </li>
    {/if}
{/if}

An <ul> is output, if the placeholder [[+wrapper]] is not empty.

{if $wrapper?}
	<ul class="level3">{$wrapper}</ul>
{/if}
1 Like