I know this is basic API stuff, but I just can’t seem to figure out how to parse through multiple array levels.
First, my document structure (simplified) looks like this:
--Level 1a
--Level 2a (has children)
--Level 3a
--Level 3b
--Level 3c
--Level 2b
--Level 2c
--Level 1b
--Level 2a (no children)
--Level 2b (no children)
--Level 2c (no children)
--Level 1c
Basically, what I’m trying to show is that I have some areas where Level 2 has children, and some where it does not.
Now, I’m using Ditto to generate the left navigation (long story on why I’m not using Wayfinder, but go with me on this). Within the Ditto &tpl, I’m doing this:
<li><a href="[[LeftNavLinkGenerator? &id=`[+id+]`]]">[+pagetitle+]</a></li>
So far, so good. What I want to do now is write the LeftNavLinkGenerator snippet, which will determine if Level 2 has children:
- If it does, it will output the [+id+] of Level 1 as the link.
- If it doesn’t, it will output the ID of Level 2 as the link.
What I’m basically trying to do when there are no children is bypass the Level 1 page. The Level 1 page is an in-between page that shows a list of its own children, so it’s unnecessary if there aren’t any. Here’s a link:
http://www2.ku.edu/~distinction/cgi-bin/liberal-arts-sciences1
As you can see, Liberal Arts & Sciences, Applied English, and Pre-Majors are the three that don’t have Level 2 children.
Can anyone help, please?