Okay I admit I think I’m having a thicko moment.
I’ve attached an image of one of the main menus in my Structure enabled site and what I was hoping to be able to do is to create the sub-navigation for the site using this plugin so that if you are in any of the sections underneath Maintenance you would get the items showing.
At the moment every single page on the site uses one single template which just shows some text for the entry. This will change as there will be different data types but for now I thought I’d keep it nice and simple for testing out the plugin.
Am I not right in thinking that I should be able to somehow use the plugin so that say for example I am in Repair & Overhaul I would get to see :
Commercial –List Of Services Military Engine Shop
or am I wrong in what this plugin does? I’ve tried setting every single parameter to all kinds of settings in the plugin and I can only ever get either all the main menu items to show or the entire links of the site but nothing that’s really of any use to me yet.
Please put me to rest on this one 😉
Best wishes,
Mark
Hi Mark, the plugin will output whatever you’ve put between the tags - won’t add any markup automatically, so if you only put {title}, it’ll only ever output the titles for every page on your site, irrelevant of level and not identifying them.
Obviously I don’t know the html markup you’re using for your menu - that’s up to you.
Have a look at my example 4 above. Copy this and strip out the {alternative-title} bits and see what it outputs. This is for 2 levels only, but should get you started.
Example 4 outputs something like the following:
<ul>
<li>
<strong class="opener"><a href="/???">Menu Title 1</a></strong>
<div class="slide">
</div>
</li>
<li>
<strong class="opener"><a href="/???">Menu Title 2</a></strong>
<div class="slide">
<ul class="drop-items level{depth}">
<li>
<span class="title">sub-menu item 1</span>
Item description
</li>
<li>
<span class="title">sub-menu item 2</span>
Item description
</li>
</ul>
</div>
</li>
</ul>Hiya,
I did actually try all the examples above in your first post but I’m (at this point anyway) not using any categories on the site so example 4 for me (not sure if it’s because of the category parameter though as I’ve tried taking it out) renders a completely blank page with no source code whatsoever.
I like what you’re saying about complete markup freedom as I’ve been having some real problems with styling the nav_sub tag that is output from Structure and I think if I’m correct that this plugin will allow me to do what I need?
At the moment though I either get the page stopping to render or all links in the site or only the very first main sections of my Structure layout. I think I am either getting completely confused somewhere or I’m just missing the point :-(
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 😉
Should be :
{exp:structure_entries}
…
{/exp:structure_entries}That would be why I was getting a blank page 😉
Off to try out the parameters now.
Best wishes,
Mark
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.
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="http://{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="http://{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 & Streamwork</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>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!
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 😉
Hopeful your fix will get me a bit further along though so waiting with baited breath 😉 😊 😉
Best wishes,
Mark
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 :(
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!).
Hiya,
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 😉
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
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.
Hiya,
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
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
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.