I would like to have a select menu for the child pages of a page in a site using the Structure plugin. However some of the pages don't have child pages so they wouldn't need the select menu to display. a) How do I create the select menu so that you will be taken to the child page when you select it in a dropdown and b) what conditional do I use to see if there are any child pages?

Currently I have a nav using:

{exp:structure:nav start_from="/{segment_1}/{segment_2}"}

Thanks in advance.

  • 1
    I thought the nav tag would only show the child lists if there was something to put in there. If there are no sub-pages then no child nav will be created. Are you seeing something different?
    – foamcow
    Nov 26, 2012 at 10:16

2 Answers 2


If I understand correctly the {exp:structure:nav} tag should do what you need. What isn't working for you?

However you might want to look at the structure entries add-on, which allows much greater flexibility.

For example, you can do stuff like this....

<ul class="toplevel">
    {exp:structure_entries depth="1" convert_html="true" status="open"}
        {if {entry_id}!='106'}
          <li class="{url_title}{if {current_parent}} parent-here
            {if {current_page}==1} parent-here{/if}"><a href="{page_uri}">{title}</a>
            {if "{title}"=="Blog"}
                    {if {total_children}>0}
                {embed="includes/_subnav" entry="{entry_id}"}

So what is happening here?

Firstly we call the structure entries tag pair which will list out the top level of "pages" set up in Structure (hence the depth="1" parameter).

We then do a check to make sure we aren't looking at entry number 106 as we want to ignore that (I can't recall why right now - it just didn't need to be in the nav but was a top level page in Structure.

Assuming it's not entry 106 we then output a list item with the name of the top level page and do a check for using the current_page parameter to output a css class to mark the current page if needed.

Then we do a check to see if we are listing the blog item - this is the embed to list the blog categories rather than sub-pages.

If we aren't outputting the blog pages then we check to see how many child pages there are to this page. If there are more than 0 then we call another embed which contains another structure entries tag pair, passing the parent page entry id to it.

    {exp:structure_entries depth="1" parent="{embed:entry}" status="open"
        <li{if {current_page}=='1'} class="here"{/if}><a href="{page_uri}">{title}</a></li>

This embed lists out 1 level of structure pages below the parent page as a straightforward list. We check if we are currently on the page concerned by looking at the current_page boolean again.

Finally we close out all the tags and we're done.

Now, this was done quite some time ago and I have a feeling that much of what I've done here is now part of the {exp:structure:nav} tag pair anyway so I would urge you take another look at that.

From memory that tag will do exactly what you are describing you want. But since you are asking this question I'm assuming it isn't. Could you tell us what it is producing and why it differs to what you need?

  • I realise that the above is just an example of what can be done but I added that to my page and it shows the parent pages of the current page. I need to figure out how to use this to get the child pages (is that what could be in the _subnav embeds?) and then I need to figure out how to use this with a dropdown select form. Out of interest though, why are the _subnavs an embed and what would you include on these?
    – Mosaik
    Nov 26, 2012 at 10:43
  • I realise my example is a bit cryptic now :) Yes, the embeds contain code to generate the sub menus. The embed is in there as a special case since this bit listed blog categories. I will update my answer with a bit of an explanation.
    – foamcow
    Nov 26, 2012 at 11:05
  • 1
    One thing to bear in mind when using Structure Entries is that it can very quickly become very query intensive, which may be an issue if you're using it for primary navigation. Be sure to use the debugger to profile your DB queries if you care about site performance...
    – Tom Davies
    Nov 26, 2012 at 15:38

To answer your second question of "what conditional do I use to see if there are any child pages?", there are two types.

Firstly, if the child pages are listings there is a global variable in Structure that does just what you need - {structure:is:listing:parent}

It returns 1 or blank for the current page, so you could use:

{if structure:is:listing:parent=="1"}
   Do what you gots to do.

If you're looking for actual Structure child pages, you could use another global variable - {structure:child_ids}

This should work:

{if structure:child_ids!=""}
   Do more of what you gots to do
  • Thank you, yes I had managed to find the {if structure:child_ids!=""} conditional and have finally got it working. Although I've left it just as a list because I'm still not sure how to make it a dropdown eg <select><option value="link to country name here">country name here</option></select>
    – Mosaik
    Dec 10, 2012 at 3:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.