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

Tyssen's avatar
Tyssen
756 posts
15 years ago
Tyssen's avatar Tyssen
With structure_entries, simply wrap all your display code with:
{if {entry_id} != 32 || {entry_id} != 42}

I’ve tried that but it doesn’t seem to be working.

I’ve got this:

{exp:query sql="SELECT entry_id AS page_id FROM ee_weblog_titles WHERE url_title='{segment_1}'"}    
{exp:structure_entries parent="{page_id}"}
{if {entry_id} != 409 || {entry_id} != 417 || {entry_id} != 421 || {entry_id} != 434}

Copied code goes here

{/if}
{/exp:structure_entries}
{/exp:query}
I’ll add to the to-do list to add current_location=“on” or something to make it self aware and relevant to the current URL.

So does that it mean it can’t currently do what I mentioned in my previous post?

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

Tyssen,

The query call prior to the structure_entries call is redundant, this will do the same: {exp:structure_entries parent="/{segment_1}”}

In your conditional you want to use && not || (apologies, my example was incorrect).

Regarding addding current_location, no I meant I could expand it to be self aware of it’s current location.

Steven’s example is to use the current URL, without having to be specific with a segment variable or entry_id for the parent.

You can output the children by specifying the parent and depth in the current version of the plugin, that works as per my example test page.

But: “To show the adjacent pages to the one you’re on” - when you refer to adjacent, do you mean siblings or children?

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

Just in case anyone else has Florian’s issues, there were a couple of things…

The code was using {page_url} (which is the specific url segment of the page - like title_url) and should have been using {page_uri} - this should be consistent with Structure variables.

The EE install was in a subfolder, which doesn’t get output by the {page_uri} variable.

And finally the site uses index.php, which again was missing from the urls.

So all that was needed was to add “/subfolder/index.php/{page_uri}” to each link, or “{site_url}{page_uri}” (there may be a forward slash needed in there too!).

       
Tyssen's avatar
Tyssen
756 posts
15 years ago
Tyssen's avatar Tyssen
In your conditional you want to use && not || (apologies, my example was incorrect).

I did actually try that at some point and it didn’t work but must’ve changed some other part while trying different things out, but it’s all good now.

But: “To show the adjacent pages to the one you’re on” - when you refer to adjacent, do you mean siblings or children?

Yes, I mean siblings, but also the parent of that page and all the parent’s siblings too, so with a structure like below:

Parent 1 -Child 1.1 -Child 1.2 -Child 1.3 Parent 2 -Child 2.1 -Child 2.2 Parent 3 -Child 3.1 etc.

when on Child 2.2 you’d see

Parent 1 Parent 2 -Child 2.1 -Child 2.2 Parent 3

and when on Child 1.1 you’d see

Parent 1 -Child 1.1 -Child 1.2 -Child 1.3 Parent 2 Parent 3

and so on.

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

Easiest method might be simply hiding the redudant markup with CSS, using the example from the first post, you could hide all secondary <ul>’s and then display the active parent…

#menu li ul { display:none; }
#menu .current ul {display:block; }

Alternatively add some more conditionals:

{exp:structure_entries}
{if {depth} == 1}{!-- Top Level --}
    <li {if {current_parent}}class="current"{/if}{if {current_page}}class="active"{/if}>
        <a href="http://{page_uri}">{title} Depth={depth} Parent={parent_id}</a>
  {if {children_total} == 0 || {current_parent} != true}{!-- No Children - so close markup --}
    </li>
  {/if}

{if:else}{!-- Children (not top level) --}
  {if {current_parent}}
  {if {sibling_count} == 1}{!-- First child - so open markup --}
        <ul class="level{depth}">
  {/if}
            <li {if {current_parent}}class="current"{/if}{if {current_page}}class="active"{/if}>
                <a href="http://{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}
{/if}
{/exp:structure_entries}

There’s two {current_parent} additions in the above - this isn’t tested, but should get you in the right direction!

       
Tyssen's avatar
Tyssen
756 posts
15 years ago
Tyssen's avatar Tyssen

Yep, that’ll do it, thanks.

       
heaversm's avatar
heaversm
197 posts
15 years ago
heaversm's avatar heaversm

I migrated my dev site to Engine hosting and get this error:

Warning: Call-time pass-by-reference has been deprecated - argument passed by value; 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. However, future versions may not support this any longer. in/www/eh13172/public_html/manage/plugins/pi.structure_entries.php on line 449
       
Peter Lewis's avatar
Peter Lewis
280 posts
15 years ago
Peter Lewis's avatar Peter Lewis

Please see post 2 Edit: http://ellislab.com/forums/viewreply/702031/

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

This is so it can parse FieldFrame fields, but I’m working on a better method which will avoid this.

If you can’t edit the PHP.ini, then let me know and I’ll send a version which excludes this call.

       
heaversm's avatar
heaversm
197 posts
15 years ago
heaversm's avatar heaversm

I actually can’t edit PHP.ini. Ironically - I am using Expression Engine’s hosting service…

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

Here you go v1.0.11 without FieldFrame support and removes the PHP error message.

       
David Guillory's avatar
David Guillory
8 posts
15 years ago
David Guillory's avatar David Guillory

Thanks for the fantastic plugin. Is it currently compatible with Structure 2.1.1 for EE2?

       
Tyssen's avatar
Tyssen
756 posts
15 years ago
Tyssen's avatar Tyssen

Actually, I seem to be having a problem with a missing closing ul tag which is making that link and its children part of the previous links’ ‘family’.

{exp:structure_entries parent="/{segment_1}"}
    {if {entry_id} != 409 && {entry_id} != 417 && {entry_id} != 421  && {entry_id} != 428 && {entry_id} != 434}
           {if {depth} == 1}<li{if {current_parent} || {current_page}} class="current"{/if}><a href="/site.php{page_uri}">{title}</a>{if {children_total} == 0}</li>{/if}
        {if:else}
          {if {sibling_count} == 1}<ul>
        {/if}
        <li><a href="/site.php{page_uri}">{title}</a>{close_markup}{if {total_children} == 0 || {depth} == {restricted_depth}}</li>{/if}
          {if {last_sibling} && {sibling_count} == {sibling_total}}</ul>
        </li>
        {/if}
        {/close_markup}
        {/if}
    {/if}
    {/exp:structure_entries}

The thing is, it only appears to be happening on one particular segment and not others. :?

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

David: No, it’s not EE2 compatible, now that Structure and various other add-ons have been released for EE2 I’ll now be using that as the main base for future development, although I will be trying out the other modules that are similar to Structure (one free, one commercial that I’m aware of). If Structure still works well compared to these, I’ll port the add-on to be compatible. This will happen quite quickly I would have thought once I start on a fresh EE2 build.

Tyssen: I think it’s to do with the if statements on the entry ID’s that are being skipped, if they’re the last sibling, it’s skipping the code to close them correctly.

{exp:structure_entries parent="/{segment_1}"}
           {if {depth} == 1}
    {if {entry_id} != 409 && {entry_id} != 417 && {entry_id} != 421  && {entry_id} != 428 && {entry_id} != 434}
<li{if {current_parent} || {current_page}} class="current"{/if}>
<a href="/site.php{page_uri}">{title}</a>{if {children_total} == 0}</li>{/if}
{/if}
        {if:else}
          {if {sibling_count} == 1}<ul>{/if}
    {if {entry_id} != 409 && {entry_id} != 417 && {entry_id} != 421  && {entry_id} != 428 && {entry_id} != 434}
        <li><a href="/site.php{page_uri}">{title}</a>
{/if}
{close_markup}
    {if {entry_id} != 409 && {entry_id} != 417 && {entry_id} != 421  && {entry_id} != 428 && {entry_id} != 434}
{if {total_children} == 0 || {depth} == {restricted_depth}}</li>{/if}
{/if}
          {if {last_sibling} && {sibling_count} == {sibling_total}}
</ul>
        </li>
        {/if}
        {/close_markup}
        {/if}

{/exp:structure_entries}

This is off the top of my head, and does now look messy. If I get a chance today, I’ll look at the possiblity of adding an exclude parameter.

What I usually do though is create a category for navigation, and then call structure_entries passing the category, that way only those options assigned to the category appear.

Peter

       
Tyssen's avatar
Tyssen
756 posts
15 years ago
Tyssen's avatar Tyssen

Yes, using categories would be a neater way of doing it, but in my case I’ve got lots of entries to show and only a handful to not show, so it’d be more useful for me to be able to do category_id=”not X” which doesn’t seem to work at the moment.

       
First 6 7 8

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.