1

I find myself struggling with some of Structure's documentation and cannot find an answer via Google either, here's the skinny:

Currently have 2 top level "pages" (2 more but are hidden because I dont need them in the nav list). Each of these have children pages and everything is dandy and working.

Top Level Page1 - overview template / Channel1
    + Child Page -- Display template / Channel2
    + Child Page -- Display template / Channel2

Top Level Page2 - overview template / Channel1
    + Child Page -- Display template / Channel2
    + Child Page -- Display template / Channel2

I now need to take those 2 "top" level pages and insert them into a select dropdown for some JS sorting on a page that isn't managed by Structure, like this:

Project Overview -- show all entries template - Channel2
    {exp:channel:entries}
    // Works well, spits out Channel2 data no prob
    //This is what I need
    <option value="{structure:parent:id}">structure:parent:name</option>

Have tried:

{exp:structure:nav start_from="/" max_depth="1"}
  <option value="{page_uri}">{title}</option>
{/exp:structure:nav}
//This code works well in nav

This yields nothing (blank code), the docs allude that using :nav sets an li which I dont want & likely causing nothing to output.

I expect because Structure isn't managing the "projects" page, finding a parent or anything to do with normal exp:channel:entries tag is the roadblock.

Thought about adding Top Level pages as children of a new 'parent' but then I'd have another list item in the main nav which we dont want.

Totally stumped :(

2 Answers 2

3

You'll need to use the Structure Entries add-on for this. Here's the basic idea (full docs can be found at the devot-ee page):

<select id="Menu" name="menu">
  {exp:structure_entries  depth="1"}
    <option value="{page_uri}" {if {current_page}}selected{/if}>{title}</option>
  {/exp:structure_entries}
</select>
6
  • That's 99% of the way there, any thoughts on how to hide the Parent I have already hidden ? Mar 25, 2013 at 5:01
  • Try this: {exp:structure_entries depth="1" hide_from_nav="yes"} taken from getsatisfaction.com/twobelowzero/topics/hide_from_nav_variable Mar 25, 2013 at 5:13
  • So damn close but no cigar. Really need to nest inside an exp:channel tag and only output info for the current entry_id, adding entry_id="XX" to the tag does nothing :( Mar 25, 2013 at 6:03
  • I guess I'm not fully grasping what you need to accomplish. Per my last comment it outputs a select menu with all top-levl nav items not hidden (in my test it works great) but your last comment has me confused. Mar 25, 2013 at 6:30
  • Try using the "include" and "exclude" parameters instead to manually specify pages to list and not list. Mar 25, 2013 at 6:34
0

For those interested and for my future self, I basically need to add id's to 2 select dropdpowns (1 for category and for one to identity which parent it belongs to) + also replicate on 2 data values for each entry.

This is all outside the Structure framework, I'm querying only the children entries with a simple exp:channel:entries but no native way to query who its parent is.

/* Simple enough to add top value entry_ids
<select name="disciplines" data-label="Filter by Disciplines">
  <option selected="selected" value="all">All Disciplines</option>
  {exp:structure_entries depth="1" hide_from_nav="yes"}
    <option value="{entry_id}">{title}</option>
  {/exp:structure_entries}
</select>

/* Bit of a no brainer getting the categories
<select name="market" data-label="Filter by Market">
<option selected="selected" value="all">All Markets</option>
  {exp:gwcode_categories style="linear" channel="project_detail" show_empty="no"}
    <option value="{cat_url_title}">{cat_name}</option>
  {/exp:gwcode_categories}
</select>

Now the fun part, mighty Croxton Stash + Structure Entries FTW

/* Simple list of relationships !!
{exp:stash:set_list name="associated" parse_tags="yes" trim="yes"}
    {exp:structure_entries  hide_from_nav="yes" parse="inward"}
        {stash:parentid}{parent_id}{/stash:parentid}
        {stash:entryid}{entry_id}{/stash:entryid}
    {/exp:structure_entries}
{/exp:stash:set_list}

THE MAGIC = match + against !!

{exp:channel:entries channel="project_detail"}
<article data-disciplines="{exp:stash:get_list name='associated' match='#{entry_id}#' against='entryid'}{parentid},{/exp:stash:get_list}"
data-market="{exp:gwcode_categories entry_id='{entry_id}' style='linear' backspace='1'}{cat_url_title},{/exp:gwcode_categories}">
... remainder of layout for product ...
{/exp:channel:entries}

Your Answer

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

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