We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: Structure Entries - Add-on for Structure module

Development and Programming

Peter Lewis's avatar
Peter Lewis
280 posts
16 years ago
Peter Lewis's avatar Peter Lewis
I tried with your example 4 code again and I still only get the whole of the navigation menu shown

Yep - that’s what it’s suppose to do, I’ve changed it now so that by default it will output everything. If you specify depth=”1”, it will only output the top level, depth=”1” top level and it’s immediate children, etc.

I’ve updated the test page to show output of a parent menu (test 3)

Which is this code:

<ul>
{exp:structure_entries parent="31"}
    <li><a href="/{page_url}">{title}</a></li>
{/exp:structure_entries}
</ul>

If you use entry_id as the parameter (I’m assuming wrapped in weblog:entries tags), then it will only output the children of the current page. But I’m assuming from what you’re saying, you’re already on the child, so it won’t output anything.

To use the path instead of the parent entry_id, it must start with a forward slash or http://, otherwise it won’t recognise it as a correct url, so try: “/{segment_1}/{segment_2}/{segment_3}/”. Assuming that is the parent not the child!

As mentioned above, because this doesn’t output any markup, it can’t tell you if you’re on the current page, and you can’t use entry_id within the tag pair, as this will be the current id for whatever is being shown. But you can use page_uri which should match the last segment.

If this continues to be an issue without a nice template code solution, then I could probably introduce a boolean variable to identify the current page.

       
Peter Lewis's avatar
Peter Lewis
280 posts
16 years ago
Peter Lewis's avatar Peter Lewis

I think Mark, you’d only want parent=”/segment_1” as the parameter (going by your example).

       
stinhambo's avatar
stinhambo
1,268 posts
16 years ago
stinhambo's avatar stinhambo

Any ideas on how to recreate class=”here”? Is there some voodoo with Structure and the segment variable I don’t get?

       
stinhambo's avatar
stinhambo
1,268 posts
16 years ago
stinhambo's avatar stinhambo
Any ideas on how to recreate class=”here”? Is there some voodoo with Structure and the segment variable I don’t get?

Just worked it out 😊

{exp:structure_entries depth="1" parent="7"}
<li{if '{exp:structure:page_slug}' == '{page_url}'} class="here"{/if}><a href="http://{page_uri}">{title} ></a></li>
{/exp:structure_entries}
       
Peter Lewis's avatar
Peter Lewis
280 posts
16 years ago
Peter Lewis's avatar Peter Lewis

Steven,

I’ve now added a new variable output to make this a little easier:

<li {if {current_page}}class="here"{/if}>

Included in v1.0.4.

       
stinhambo's avatar
stinhambo
1,268 posts
16 years ago
stinhambo's avatar stinhambo

Good job 😊

       
bryan2jumpstart's avatar
bryan2jumpstart
98 posts
16 years ago
bryan2jumpstart's avatar bryan2jumpstart

Another thing this is good for is creating a google sitemap from structure. Would be nice to include some type of exclude parameter like structure has so items I have set to a certain status do not get shown in the sitemap. Here is my template code for others.

<?xml version="1.0" encoding="UTF-8"?>
<urlset >
{exp:structure_entries depth="1"}
<url>
<loc>http://domain.com{page_uri}</loc>
<lastmod><?=date("Y-m-d",strtotime({edit_date}))?></lastmod>
<changefreq>monthly</changefreq>
0.5</priority>
</url>
{/exp:structure_entries}
</urlset>
       
Peter Lewis's avatar
Peter Lewis
280 posts
16 years ago
Peter Lewis's avatar Peter Lewis

bryan2jumpstart: v1.0.5 now supports status (would you mind giving it a try please).

“closed” Status is now ignored by default, unless you specify status=”closed” in the parameter. Currently it only supports 1 status value (I’ll code it to handle multiples when I have more time!).

       
Peter Lewis's avatar
Peter Lewis
280 posts
16 years ago
Peter Lewis's avatar Peter Lewis

bryan2jumpstart:

Would be nice to include some type of exclude parameter like structure has so items I have set to a certain status do not get shown in the sitemap.

Also {status} can be pulled from within the tag pair, so you could build if statements to exclude anything…

{exp:structure_entries depth="1"}
{if "{status}" == "open"}
...
{/if}
{/exp:structure_entries}
       
bryan2jumpstart's avatar
bryan2jumpstart
98 posts
16 years ago
bryan2jumpstart's avatar bryan2jumpstart

Yeah that’s what I did after the fact, nice plugin

       
Adrienne L. Travis's avatar
Adrienne L. Travis
213 posts
16 years ago
Adrienne L. Travis's avatar Adrienne L. Travis

Just a quick question: is this for Structure 2 only, or will it work on the older free version (1.x) as well?

Adrienne

       
bryan2jumpstart's avatar
bryan2jumpstart
98 posts
16 years ago
bryan2jumpstart's avatar bryan2jumpstart

Using it on 1.3.1 right now

       
Adrienne L. Travis's avatar
Adrienne L. Travis
213 posts
16 years ago
Adrienne L. Travis's avatar Adrienne L. Travis

Excellent! Thanks for the info, bryan2jumpstart – this will solve a TON of problems for me with one particular client site (which i can’t upgrade to 2.0 because it’s a large MSM site and the cost is prohibitive. Otherwise i totally would. Sigh.)

       
Studio Breakfast's avatar
Studio Breakfast
7 posts
about 16 years ago
Studio Breakfast's avatar Studio Breakfast

Fantastic! Thanks for this great job! I dreamed about - you’ve make it : )

Next dream… beautiful blond girl in my dev team? : )

       
mikec964's avatar
mikec964
18 posts
about 16 years ago
mikec964's avatar mikec964

I’d like to create one template for listing the entries of any listing page. How can I figure out the weblog assigned to a particular listing page?

For example:

I have three weblogs called static_pages, news, and calculators. My site looks like this:

home (static_pages) about_us (static_pages) whats_new (static_pages) LISTING OF: news. our_calculators (static_pages) LISTING OF: calculators.

Is there a way to read Structure’s database to figure this out?

       
1 2 3 4 5 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.