EllisLab text mark
Advanced Search
1 of 8
1
   
Plugin: Structure Entries - Add-on for Structure module
Posted: 25 January 2010 09:03 AM   [ Ignore ]
Avatar
Joined: 2007-10-17
297 posts

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} 
== || {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

File Attachments
structure_entries-plugin-v1.0.11.zip  (File Size: 8KB - Downloads: 272)
 Signature 

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

 
Posted: 25 January 2010 09:07 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2007-10-17
297 posts

To get it to display FieldFrame fields, including FF Matrix, you need to do the following hack (sorry!)...

The 2 tweaks to FieldFrame are the following to the ext.fieldframe.php file (based on v1.3.5):

line 2177 from:

function _parse_tagdata(&$tagdata$fields) 

To:

function _parse_tagdata(&$tagdata$fields$call_hook=TRUE) 

line 2232 from:

$new_tagdata call_user_func_array(array(&$field['ftype']$tag_func), array($params$field_tagdata$field['data']$field['settings']))

To:

$new_tagdata call_user_func_array(array(&$field['ftype']$tag_func), array($params$field_tagdata$field['data']$field['settings']$call_hook)); 

EDIT: Because of the PHP errors reported under PHP v5.0.3, this functionality isn’t enabled by default, so please download the version attached to this post.  To avoid getting the PHP error message, you’ll need to add the following to your PHP.ini (may need to search for it as it will probably already exist but set to false or off):
allow_call_time_pass_reference=true

All the above isn’t a fantastic solution, but as I’m tapping into the existing code of FieldFrame, it’s the only way currently.  I’m working on a better method without any hacking, which should be available soon.

 Signature 

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

 
Posted: 25 January 2010 09:57 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

Hiya,

Not sure what all this means but I just tried using the plugin by simply plonking it into an existing template used within Structure and I got this error message :

Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. in /usr/local/psa/home/vhosts/*******.com/httpdocs/admin/plugins/pi.structure_entries.php on line 349

Best wishes,

Mark

 Signature 

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

 
Posted: 25 January 2010 10:56 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2007-10-17
297 posts

Hmmm, I had so much grief from that one line - it relates to the call to the FieldFrame class, so I have disabled FieldFrame support on the plugin and re-uploaded.  I can only assume that your version of PHP doesn’t like the “&” (which sends the variable by reference).

 Signature 

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

 
Posted: 25 January 2010 11:02 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts
Twobelowzero - 25 January 2010 03:56 PM

Hmmm, I had so much grief from that one line - it relates to the call to the FieldFrame class, so I have disabled FieldFrame support on the plugin and re-uploaded.  I can only assume that your version of PHP doesn’t like the “&” (which sends the variable by reference).

Is the new version uploaded yet as I’m still getting that same error I’m afraid :-(

Just tried downloading from the link above again but still the same I’m afraid.

Best wishes,

Mark

 Signature 

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

 
Posted: 25 January 2010 11:15 AM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2007-10-17
297 posts

Yep, I had re-uploaded, but I expect it was a browser cache issue, as it had the same filename.  Actually Mark I had emailed it directly to you after I read your first comment.

I’ve now commented out the entire offending function and re-uploaded with a different filename, so fingers crossed!

Out of interest, do you know what PHP version you’re testing on?

Thanks.

 Signature 

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

 
Posted: 25 January 2010 11:34 AM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

Hiya,

The new link at the top of this thread now gets rid of the error but the one you sent across in the e-mail didn’t. Saying that I’m not entirely certain what the plugin should be doing as I have the version which is at the top of this thread installed and I tried with the basic example that you showed above :

{exp:structure_entries}
  {title}
{
/exp:structure_entries} 

If I place this into a new template or an existing template used by Structure then I just get my normal page template output, nothing extra showing anywhere.

Not sure what I’m doing wrong?

Best wishes,

Mark

P.S. PHP Version is 5.2.3

 Signature 

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

 
Posted: 25 January 2010 11:49 AM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2007-10-17
297 posts

Hmmm, my PHP is v5.2.5, so doubtful that’s the issue.  Leave that for another day…

The one emailed to you only had the call commented, the one on this thread now has the whole function commented out.

Just tested this on it’s own template:

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

Here’s the results.

What version of Structure are you using?  If you don’t mind helping debug this issue, can you email me please?

 Signature 

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

 
Posted: 25 January 2010 12:08 PM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

Hiya,

Twobelowzero - 25 January 2010 04:49 PM

Hmmm, my PHP is v5.2.5, so doubtful that’s the issue.  Leave that for another day…

The one emailed to you only had the call commented, the one on this thread now has the whole function commented out.

Just tested this on it’s own template:

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

Here’s the results.

What version of Structure are you using?  If you don’t mind helping debug this issue, can you email me please?

Hmm very very strange. I just tried the code that you’ve posted that I’ve quoted and that seems to be working!

I have absolutely no idea why it didn’t work previously though. I thought it might have been a copy paste error from the forums but I re-typed it in myself and it still didn’t work. Really not sure why it just suddenly started working though, very very strange.

Off to have a play with this now.

Best wishes,

Mark

 Signature 

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

 
Posted: 25 January 2010 12:27 PM   [ Ignore ]   [ # 9 ]   [ Rating: 0 ]
Avatar
Joined: 2007-02-16
408 posts

This looks really nice. The Structure nav markup is already pretty nice, but this will come in handy for those crazy navigation menus some designers cook up.

 Signature 

@litzinger
Bold Minded add-ons

 
Posted: 25 January 2010 02:41 PM   [ Ignore ]   [ # 10 ]   [ Rating: 0 ]
Avatar
Joined: 2007-03-07
33 posts

Hi,

I need to get only the first (root) level for use in a main navigation, but depth=“1” seems to go down one level and 0 displays all levels. Is there any way to get only the first one?

The reason I’m not using Structure’s native nav_main function is that I have to show the second level for only one of them. So I need an if statement inside the tag pair, which isn’t possible with Structure on its own as it only uses single tags.

Any clever solution to my problem..?

 
Posted: 25 January 2010 06:12 PM   [ Ignore ]   [ # 11 ]   [ Rating: 0 ]
Avatar
Joined: 2007-10-17
297 posts

depth=“1” should work fine, as that’s what I’m using on the northstar example above - it only shows the top level. If it doesn’t let me know what version of Structure you’re using.

But, because you want to show 1 of the menus with it’s children, you should set it to depth=“2”, then have an IF looking for the relevant parent id.

<ul>
{exp:structure:entries depth="2"}
  {if {depth} 
== || {parent_id} == xx}{!-- Top Level or specific parent for 2nd level --}
  
<li><a href="{page_uri}">{title}</a></li>
  
{/if}
{
/exp:structure:entries}
</ul

Replace the “xx” for the entry_id of the page that has the dropdown list of children (assume it is a parent inside Structure).

The above assumes you want all top level pages displayed, you can use a category to restrict this display if need be.

 Signature 

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

 
Posted: 25 January 2010 06:15 PM   [ Ignore ]   [ # 12 ]   [ Rating: 0 ]
Avatar
Joined: 2007-10-17
297 posts

Actually, you should also be able to do this via a category without the if statement, and have only the sub-pages (level 2) you want shown set to the category, so if the children aren’t set to that category, they won’t be shown.  This is also a way of showing some of the children, not all.

 Signature 

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

 
Posted: 25 January 2010 06:50 PM   [ Ignore ]   [ # 13 ]   [ Rating: 0 ]
Avatar
Joined: 2007-03-07
33 posts

Thanks for your reply.
But I dont get the depth attribute to work. I have two levels of pages set up in Structure and using

{exp:structure_entries depth="1"

But it just spits out a linear list with both levels in it.

I’m using Structure and 2.0.6 and downloaded your plugin today.

 
Posted: 25 January 2010 10:45 PM   [ Ignore ]   [ # 14 ]   [ Rating: 0 ]
Avatar
Joined: 2007-01-05
1427 posts

Fantastic! I was disappointed that I couldn’t do this on a current project only yesterday so this is unbelievably timely!

 Signature 

Steven Hambleton | Hambo Development

WE SPECIALISE IN WORKING WITH AGENCIES AND BUILDING LONG TERM DEVELOPMENT PARTNERSHIPS 
 
Posted: 26 January 2010 09:53 AM   [ Ignore ]   [ # 15 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

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 wink

Best wishes,

Mark

Image Attachments
Structure Menu.png
 Signature 

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

 
1 of 8
1