Loop exists / if empty
-
Hi,
I’m looping though hierarchical pages to build a menu and need to distinguish pages with sub pages from the ones that don’t have sub pages.
The final output should look like that:
PAGE 1 (has sub pages) - SUB PAGE PAGE 2 PAGE 3 (has sub pages) - SUB PAGEHere’s my code:
<ul> [loop type=page parent=top-parent-page orderby=menu] [-loop exists parent=this orderby=menu] <li class="has-submenu">[field title-link] <ul class="submenu"> [the-loop] <li>[field title-link]</li> [/the-loop] </ul> </li> [if empty]<li>[field title-link]</li>[/if] [/-loop] [/loop] </ul>The nested loop fetches sub pages if the loop’s not empty, and i use
[if empty]for the pages without children.The problem is
[if empty]doesn’t output anything and i get this result:PAGE 1 - SUB PAGE PAGE 3 - SUB PAGEPage 2 (no children) is removed.
[Update] Actually i realize
[the-loop]doesn’t output anything here either.Any idea please?
Thanks for your help. 😉
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Loop exists / if empty’ is closed to new replies.