2 of 7
2
Plugin: Structure Entries - Add-on for Structure module
Posted: 26 January 2010 10:06 AM   [ Ignore ]   [ # 19 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13771
Joined  04-15-2006

Okay just realised where this is starting to go wrong!

You have in your code examples above :

{exp:structure:entries}

{
/exp:structure:entries} 

Spot the mistake anyone wink

Should be :

{exp:structure_entries}

{
/exp:structure_entries} 

That would be why I was getting a blank page wink

Off to try out the parameters now.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 26 January 2010 10:31 AM   [ Ignore ]   [ # 20 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13771
Joined  04-15-2006

Okay now I have the plugin working but still can’t seem to get it to output anything that I’m looking for. Forgetting the styling of the list for the moment as that’s something I’d have to work on I just can’t get anything relating to the page I’m on outputting. I either get a list output which is just the very first item in Structure or the whole list but not anything relating to the page I’m currently on.

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 26 January 2010 10:38 AM   [ Ignore ]   [ # 21 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  308
Joined  10-17-2007

Completely blank page isn’t good :(

Looking at your other post, yes this will/should sort the issue out.  What version of Structure are you using?

The following is theory, not an actual working copy…

Template:

<ul>
{exp:structure_entries depth="2"}
{if {depth} 
== 1}{!-- Top Level --}
  
<li>
    <
a href="{page_uri}">{title}</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}</a></li>
  
{if {last_sibling}}{!-- Last Child so close markup --}
      
</ul>
  </
li>
  
{/if}
{
/if}
{
/exp:structure_entries}
</ul

Output:

<ul>
    <
li><a href='/operations/'>Overview</a></li>
    <
li><a href='/operations/flight_operations/'>Flight Operations</a>
        <
ul class="level1">
            <
li><a href='/operations/flight_operations/forestry_streamwork/'>Forestry &ampStreamwork</a></li>
            <
li><a href='/operations/flight_operations/petroleum_exploration/'>Petroleum Exploration</a></li>
            <
li><a href='/operations/flight_operations/construction/'>Construction</a></li>
            <
li><a href='/operations/flight_operations/fire_fighting/'>Fire Fighting</a></li>
            <
li><a href='/operations/flight_operations/movies/'>Movies</a></li>
            <
li><a href='/operations/flight_operations/disaster_relief/'>Disaster Relief</a></li>
        </
ul>
    </
li>
    <
li><a href='/operations/our_aircraft/'>Our Aircraft</a>
        <
ul class="level1">
            <
li><a href='/operations/our_aircraft/columbia_model_234_ut/'>Columbia Model 234 UT</a></li>
        </
ul>
    </
li>
    <
li><a href='/operations/safety_standards/'>Safety Standards</a></li>
</
ul
 Signature 

twobelowzero
EE add-ons support and comments
EE Shopping Cart and ecommerce solution (coming soon)

Profile
 
 
Posted: 26 January 2010 10:41 AM   [ Ignore ]   [ # 22 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  308
Joined  10-17-2007

OK, I know what’s going wrong.  This code was within the module itself, hence the examples I’ve copied were part of the Structure module, and I haven’t changed the examples since I pulled it out.  Chances are I’ve missed something in the plugin version and have made the same mistake in my tests.

Give you an update in a bit!  Tsk.

Update: New version has correct examples and have updated first post!

 Signature 

twobelowzero
EE add-ons support and comments
EE Shopping Cart and ecommerce solution (coming soon)

Profile
 
 
Posted: 26 January 2010 10:47 AM   [ Ignore ]   [ # 23 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13771
Joined  04-15-2006
Twobelowzero - 26 January 2010 03:41 PM

OK, I know what’s going wrong.  This code was within the module itself, hence the examples I’ve copied were part of the Structure module, and I haven’t changed the examples since I pulled it out.  Chances are I’ve missed something in the plugin version and have made the same mistake in my tests.

Give you an update in a bit!  Tsk.

Do you want me to try the code above then or is that wrong? I’m pretty sure that I’m not doing anything too wrong as I just can’t get it to output anything relating to the page so hopefully your fix will sort that all out.

As to the blank page, did you see my other post above? I noticed that your examples had this code :

{exp:structure:entries} 

instead of :

{exp:structure_entries} 

I didn’t even see that the first couple of times that I copied the code wink

Hopeful your fix will get me a bit further along though so waiting with baited breath wink grin wink

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 26 January 2010 10:52 AM   [ Ignore ]   [ # 24 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  308
Joined  10-17-2007

Mark, this plugin is independent to the page you’re on, so to find that out you’d do something like {if “{segment_1}” == “{page_uri}”} or something similar.

The above code should work in theory, it’s based on my working copy from the Angulo site.  Albeit I’d have to replicate your page structure to fully test.  I’ve updated the plugin, but only to amend the examples.

Edit: Just built an example using that code and it’s not working.  Will fix now :(

 Signature 

twobelowzero
EE add-ons support and comments
EE Shopping Cart and ecommerce solution (coming soon)

Profile
 
 
Posted: 26 January 2010 11:16 AM   [ Ignore ]   [ # 25 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  308
Joined  10-17-2007

Right, by default if you don’t pass a depth, it reverts to depth=1, but these seems to output everything and pretend it’s all depth level 1.  Helpful.

So in the example above I’ve added depth=“2” to the parameter and it outputs the depths correctly, thus the formatting, you can see the results here:
www.northstarenergy.co.uk/test (scroll down to “Test 2”.

But as you can see, it’s still outputting all depths, and not limiting itself to what you’ve specified.  Annoying, but it should give you enough to play with till I fix it (later today hopefully!).

 Signature 

twobelowzero
EE add-ons support and comments
EE Shopping Cart and ecommerce solution (coming soon)

Profile
 
 
Posted: 26 January 2010 11:26 AM   [ Ignore ]   [ # 26 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13771
Joined  04-15-2006

Hiya,

Twobelowzero - 26 January 2010 04:16 PM

Right, by default if you don’t pass a depth, it reverts to depth=1, but these seems to output everything and pretend it’s all depth level 1.  Helpful.

So in the example above I’ve added depth=“2” to the parameter and it outputs the depths correctly, thus the formatting, you can see the results here:
www.northstarenergy.co.uk/test (scroll down to “Test 2”.

Yep I tried this in one of the tests but still got everything output as you have there so I really thought I was doing something wrong somewhere wink

Twobelowzero - 26 January 2010 04:16 PM

But as you can see, it’s still outputting all depths, and not limiting itself to what you’ve specified.  Annoying, but it should give you enough to play with till I fix it (later today hopefully!).

Yep at least I can get the list to output and then I can play around with styling and what-not.

This will be an absolute life-saver once fixed so thanks a load for this one. Definitely looking forward to a new version.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 26 January 2010 03:50 PM   [ Ignore ]   [ # 27 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  308
Joined  10-17-2007

New version (v1.0.3) uploaded here (or see first post).

All issues should be resolved now, I’ve also updated the example 4 to output correct html markup for any depth of page.

Any probs, please shout.

 Signature 

twobelowzero
EE add-ons support and comments
EE Shopping Cart and ecommerce solution (coming soon)

Profile
 
 
Posted: 26 January 2010 06:15 PM   [ Ignore ]   [ # 28 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13771
Joined  04-15-2006

Hiya,

Twobelowzero - 26 January 2010 08:50 PM

New version (v1.0.3) uploaded here (or see first post).

All issues should be resolved now, I’ve also updated the example 4 to output correct html markup for any depth of page.

Any probs, please shout.

Thanks for the update but I think I might still be missing something?

Let’s say this is my entire site in Structure :

Operations
—Flight Operations
——Forestry & Streamwork
——Petroleum Exploration
——Construction
—Our Aircraft
——Model 234 UT
—Safety Standards

Maintenance
—Repair & Overhaul
——Commercial
————List Of Services
——Military
——Engine Shop
—Capabilities List
—Certifications

Business
—Flight Operations
—Military Maintenance
—Commercial Maintenance

Employment
—Employment Procedures

About Us
—Mission Values
—Company History

News
—Photo Gallery
—Video Gallery

Store
—PDF Catalog

Let’s say for instance I was on the Petroleum Exploration page which is http://www.example.com/operations/flight_operations/petroleum_exploration should I now be able to create a sidebar navigation menu which only shows me the Maintenance section (everything in bold in the menu outlined above) and also to be able to somehow make the Petroleum Exploration be shown as the currently visited page?

I tried with your example 4 code again and I still only get the whole of the navigation menu shown i.e. the whole of the menu outlined above. What I’d like is t only show the section that you are currently in. Is that possible at all? If not then I think I’m missing the point of this plugin. That’s definitely not meant as an insult - far from it - I have just misunderstood what it’s for though if that’s the case.

Hope you can shed some light on this for me.

Thanks again for all the hard work on this one it’s much appreciated.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 26 January 2010 06:23 PM   [ Ignore ]   [ # 29 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13771
Joined  04-15-2006

Just as a quickie to my post above I’m just wondering how exactly you use the parent=”{entry_id}” parameter or you also mention that this parameter can be the path to the parent too?

I tried setting the parameter to {entry_id} but that doesn’t seem to make any difference to the output at all. I’ve tried setting it to ”{segment_1}/{segment_2}/{segment_3}/” and various other mixes but none of these seem to work?

I’m guessing if I can get the parent part to work then this should then just spit out what I want but taking your example 4 I can see in the whole menu that is output that the parent equals numbers which I would obviously need to set dynamically but I’m just not sure how I’d go about doing that?

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 27 January 2010 05:22 AM   [ Ignore ]   [ # 30 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  308
Joined  10-17-2007

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.

 Signature 

twobelowzero
EE add-ons support and comments
EE Shopping Cart and ecommerce solution (coming soon)

Profile
 
 
Posted: 27 January 2010 05:25 AM   [ Ignore ]   [ # 31 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  308
Joined  10-17-2007

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

 Signature 

twobelowzero
EE add-ons support and comments
EE Shopping Cart and ecommerce solution (coming soon)

Profile
 
 
Posted: 28 January 2010 12:56 AM   [ Ignore ]   [ # 32 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1642
Joined  01-05-2007

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

 Signature 

Steven Hambleton | Hambo Development

WE SPECIALISE IN WORKING WITH AGENCIES AND BUILDING LONG TERM DEVELOPMENT PARTNERSHIPS 
Profile
 
 
Posted: 28 January 2010 01:04 AM   [ Ignore ]   [ # 33 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1642
Joined  01-05-2007
stinhambo - 28 January 2010 05:56 AM

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 smile

{exp:structure_entries depth="1" parent="7"}
<li{if '{exp:structure:page_slug}' == '{page_url}'class="here"{/if}><a href="{page_uri}">{title} ></a></li>
{/exp:structure_entries} 
 Signature 

Steven Hambleton | Hambo Development

WE SPECIALISE IN WORKING WITH AGENCIES AND BUILDING LONG TERM DEVELOPMENT PARTNERSHIPS 
Profile
 
 
Posted: 28 January 2010 06:49 AM   [ Ignore ]   [ # 34 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  308
Joined  10-17-2007

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.

 Signature 

twobelowzero
EE add-ons support and comments
EE Shopping Cart and ecommerce solution (coming soon)

Profile
 
 
Posted: 28 January 2010 07:57 AM   [ Ignore ]   [ # 35 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1642
Joined  01-05-2007

Good job smile

 Signature 

Steven Hambleton | Hambo Development

WE SPECIALISE IN WORKING WITH AGENCIES AND BUILDING LONG TERM DEVELOPMENT PARTNERSHIPS 
Profile
 
 
Posted: 28 January 2010 12:58 PM   [ Ignore ]   [ # 36 ]  
Lab Assistant
RankRank
Total Posts:  111
Joined  02-05-2009

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>
<
priority>0.5</priority>
</
url>
{/exp:structure_entries}
</urlset
 Signature 

JumpStart Web Services

Profile
 
 
   
2 of 7
2