2

I always end up with a custom addon for outputting the nav from Structure but for this project I was hoping to go all native .. it should be pretty simple, after all.

Given this Structure structure how could one output the menu to the right?: Structure, structure.

The nav tag won't cut it as it will always output the root. Am I missing something?

{exp:structure:nav include_ul="no" start_from="/" max_depth="2"}
    <li><a href="{page_uri}">{title}</a></li>
{/exp:structure:nav}

// NOTE: I do know about the Structure Entries plugin but AFAIK this will use {title} for the page titles which means it won't work inside a {exp:channel:entries} loop w/o using an embed.

1

I have done something similar but I think it won’t work in Structure 3.3.7 and later ([Feature] Fix for nesting pages under “Home” (url of “/”). No longer allowed.).

Let’s assume your home page has the entry_id 1:

{exp:channel:entries
    fixed_order="{exp:structure:child_ids entry_id='1'}"
    parse="inward"
    }
    <li{if "{page_url}" == "{structure:page:url}"} class="active"{/if}>
        <a href="{page_url}">{title}</a>
    </li>
{/exp:channel:entries}

This should work up to Structure 3.3.6.

{exp:structure:child_ids} is not documented in the current Structure documentation but you can find it in the EE1 Structure docs and Travis (or Jack?) assured me that it won’t be gone anytime soon. It looks like you can use {structure:child_ids_for:XXX} since Structure 3.3.5. But I have not tried it.

To output the menu in a {exp:channel:entries} loop I would use More Entries plugin or Stash (of course).

I have not tried it, but it seems like you can use {exp:structure:entries} tag instead of {exp:channel:entries} since Structure 3.3.7. Too bad nesting pages under “Home” is not allowed since the same version. :-(

May be this thread in Structure’s support forum could be helpful too.

| improve this answer | |
5

You should be able to just do:

{exp:structure:nav include_ul="no" start_from="forside" max_depth="1"}

You can pick what page you want to start from, which in this case looks like "forside".

| improve this answer | |
  • That's what I'm doing but it doesn't work as it will include "forside" (which has the URL / btw what's why I'm using start_form="/"). start_from="/" and max_depth="1" will only output "Forside" – Bjørn Børresen Jan 4 '13 at 15:01
  • Ahhh, yes i see the issue. Structure isn't designed to add subpages to the "home" or root page, as the urls are completely indistinguishable. In fact, we've disabled the ability to add pages to that particular page in our in-dev version to avoid confusion. Any reason why you can't just add them to the "top level"? – Jack McDade Jan 4 '13 at 15:05
  • Hmm, well generally I think it makes more sense to have the "Frontpage" as the root if it contains content that should be editable. So I've created a field group for the frontpage, and one for the subpages. That way the user can edit everything from the Structure panel. I guess an alternative could be to have the subpages on the same level as the frontpage ... but I think it's more logical that they are children, .. because well they are children of the frontpage :-) .. and also I have multilingual cases where you have multiple frontpages for instance (/ <- main frontpage, /en <-english etc) – Bjørn Børresen Jan 4 '13 at 15:19
  • Structure is definitely designed to have them on "the same level", as 99.9% of the time people put "Home" right on the save level of nav as the rest of of the pages (e.g. About, Contact Us, etc). So while the url is "/", they act like sibling pages. It may be a "gotcha" of sorts, but that's how Structure has worked for 5ish years now and we've had only a handfull of cases in its history where people needed it differently. I would recommend putting them on the same level, and if you need to do multi-lingual, Transcribe is a great tool to help facilitate that. – Jack McDade Jan 4 '13 at 15:37
  • @JackMcDade Can he use the exclude parameter to exclude the entry ID of that top-level page? – kmgdev Jan 4 '13 at 17:36
0

Another option is to use {exp:structure:nav include_ul="no" start_from="forside" max_depth="1" add_unique_ids="yes"}... note the added add_unique_ids="yes" parameter.

With unique IDs added, you can use CSS to hide the home page link as needed.

| improve this answer | |
0

If you never want the frontpage output in the menu, how about just hiding it from the navigation tag altogether (by setting "Hide from nav" to "yes" in the structure tab)?

| improve this answer | |
  • That won't work as this will also hide all the children. – Bjørn Børresen Jan 8 '13 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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