Structure Entries v1.0.11 (16th June 2010) attached to this post.
For support please post here: Get Satisfaction. Please don’t send issues to Travis/BuildWithStructure.
Extends the excellent Structure module with a tag pair allowing you to output your Structure managed pages with your own html markup (for a menu, summary page, bullet points, whatever), with control on the depth of parent/child and doesn’t need to sit inside {exp:weblog:entries} tag pair. It also supports categories.
Obviously you’ll need Structure installed!
Change Log:
v1.0.8 Fix for status, default if no status specified is != ‘closed’
Fix for EE update (v1.6.9) - page URI
Added new variable {current_parent} which is set to true if parent of current page
v1.0.9 Fix for current_parent variable not working! Tsk!
v1.0.10 Bug fix for limiting depth and close markup not closing parents with deeper children. Also updated examples.
v1.0.11 License change
Code:
{exp:structure_entries depth="2" parent="10" category_id="7" limit="4"}
...
Your html markup and EE Fields.
...
{/exp:structure_entries}
It’s a tag pair, so always needs the closing tag. All parameters are optional, defaults are shown below.
Parameters:
depth - to restrict how deep the output is (defaults to 0 - all)
parent - to only show the children beneath the specified parent (including grand-children, etc). This can be either the entry_id of the parent or the path to the parent.
category_id - the category ID that you want shown - only entries (including children) assigned to the specified category will be shown.
limit - restricts the output so only the amount of pages you specify will be shown (handy for summary pages, where you might only want to show a few of the child pages). Default is unlimited.
status - limit output to a specific status (can only handle one status), by default outputs all status except “closed”.
Variables:
Additional variables available (beyond the standard EE fields and custom fields) include:
{page_uri} = Is the entry URL value
{page_url} = Is the URL to the entry as returned by Structure
{current_page} = returns 1 (true) if the current page matches the page output by the entries loop
{depth} = Displays the current level of pages deep this page is (how many parents it has)
{parent_id} = Entry ID for the parent of the current page, if it’s top level, it returns 0
{count} = running counter for all entries that match the supplied parameters
{total_children} or {children_total} = Total entries that match the supplied parameters (depth, parent & category)
{last_child} or {last_sibling} = Returns true or false boolean to indicate if the entry is the last sibling in the current group and level of entries
{sibling_count} = running counter of siblings working through the current group at the same level
{total_siblings} or {sibling_total} = total siblings for the current group at this level
As of v1.0.7 a tag pair:
{close_markup}{/close_markup} = Parsed once the entries loop reaches the last entry it it’s current branch, then repeats the pair through all parents, allowing you to close the markup.
Examples:
Example 1 (very basic):
{exp:structure_entries}
{title}
{/exp:structure_entries}
Which will list all structure entries (any depth/level) and any fieldname/variable specified within the template tags will be shown.
FF Matrix is supported with a very minor amend to the FieldFrame code.
Example 2:
{exp:structure_entries parent="10" depth="1"}
<li {if {current_page}}class="current"{/if}>
<a href="{page_uri}"><img src="{theme-url}/images/{page_url}.gif" alt="{if " /></a>
</li>
{/exp:structure_entries}
Displays the children (1 level) of a specific parent, using images and custom fields as an alternative to {title}.
Example 3:
{exp:structure_entries category_id="6" depth="1"}
<li {if {current_page}}class="current"{/if}>
<a href="{page_uri}">{if "{alternative-title}" != ""}{alternative-title}{if:else}{title}{/if}</a>
</li>
{/exp:structure_entries}
Example 4:
<ul>
{exp:structure_entries}
{if {depth} == 1}{!-- Top Level --}
<li>
<a href="{page_uri}">{title} Depth={depth} Parent={parent_id}</a>
{if {children_total} == 0}{!-- No Children - so close markup --}
</li>
{/if}
{if:else}{!-- Children (not top level) --}
{if {sibling_count} == 1}{!-- First child - so open markup --}
<ul class="level{depth}">
{/if}
<li>
<a href="{page_uri}">{title} Depth={depth} Parent={parent_id}</a>
{close_markup}
{if {total_children} == 0 || {depth} == {restricted_depth}}
</li>
{/if}
{if {last_sibling} && {sibling_count} == {sibling_total}}
</ul><!-- End of level{depth} closing tags -->
</li>
{/if}
{/close_markup}
{/if}
{/exp:structure_entries}
</ul>
This will output any level of page depth with correct opening and closing of the list markup.
For support, help & comments please post here: Get Satisfaction
