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
about 16 years ago
Peter Lewis's avatar Peter Lewis

Think I know what you’re after, “whats_new” would list out all the entries in news?

I use segment_1 to identify the weblog, then just place “weblog=”{segment_1}” as a parameter in {exp:weblog:entries}.

But in your case this would be more suitable - a series of if statements in your index template that link to a shared embed:

{if segment_1 == "whats_new"}
    {embed=includes/listing weblog="news"}
{if:else segment_1 == "our_calculators"}
    {embed=includes/listing weblog="calculators"}
{/if}

Then in your embed “listing” template:

{exp:weblog:entries weblog="{embed:weblog}" disable="member_data|pagination|trackbacks" dynamic="off" }
        ...

The structure entries plugin doesn’t list out child listing pages.

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

That’s exactly my goal. However, I wanted to do this without having to maintain the if/else template. Since my post, I’ve created this, maybe someone else will find it useful. It will continue to work even if the url_title of the listing page is changed, or even if the weblog to list is changed.

Now, to list the entries for a structure listing page, just embed _list-folder.

<!-- file: _list-folder -->
{exp:weblog:entries}
<?php
    // process php on output
    /* 
    This query works with the Structure module.
    For a listing page, it looks up the name of the associated weblog to list.
    Because we need to process results by EE, we call an embed.
    */
    $sql_query = <<<EOT
    
        SELECT     blog_name AS sql_results
        FROM    exp_weblogs AS w
                INNER JOIN exp_structure AS s
                    ON    w.weblog_id = s.listing_wid
                    AND    s.entry_id = '{entry_id}'

EOT;
?>
<!-- sql_query=<?=$sql_query?> -->
{embed="includes/_list-folder2" tQuery="<?=$sql_query?>"}
{/exp:weblog:entries}

The second file runs the query to figure out the weblog name, then lists the results.

<!-- file: _list-folder2 -->
{exp:query sql="{embed:tQuery}"}
<!-- sql_results={sql_results} -->

    <ul class="list-weblog-{sql_results}">
        {exp:weblog:entries weblog="{sql_results}" dynamic="off" disable="categories|member_data|pagination|trackbacks|comments"}
            <li {if count==total_results}class="last" {/if}>
                <a href="http://{page_url}">{title}</a>
                <div>{description}</div>
            </li>
        {/exp:weblog:entries}
    </ul>
{/exp:query}

I wish there were a Structure tag that would return the name of the weblog to list, so I could avoid the PHP complexity. Or I wish there were a way to make this work in a single file.

Anyway, maybe this will help the next person. Or someone will see this and point out a better way of doing it.

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

Oh, I just realized that the count=total_results in the code above doesn’t work to correctly apply the “last” class to the LI tag. The variables are set to 1 by the outer exp:query. It would require another level of embedding to fix this.

       
Thorvalt's avatar
Thorvalt
23 posts
15 years ago
Thorvalt's avatar Thorvalt

First of all, really nice plugin… Only having one problem, im trying to build dropdown nav and it’s working almost ok but when i’m on a child page I want that the parent gets an class current. How can this be achieved? I’m using structue 2.0.8..

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

Can you tell the current parent via the url? e.g. on the loop that outputs the parent can you compare {page_url} to {segment_1}?

Obviously {current_page} only indicates the specific page.

If you can’t solve, drop me an email and I’ll try and code something for you.

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

Had a temporary request (it was removed from the support site before I could reply!) for the parsing of FF Matrix fields. This can be done quite easily, and works fine on my builds and for other testers, so I will be re-introducing in the next version. In the meantime, send me a PM and I’ll send you a version with FFMatrix parsing activated.

       
GabrielZ's avatar
GabrielZ
1 posts
15 years ago
GabrielZ's avatar GabrielZ

Greetings,

I am developing a site and am using EE for the first time. Absolutely love Structure, but the default menu layout will not work for me this time. I’m trying to figure out how to do this using the plugin, but the syntax is new to me and I can’t get it to work.

This is for a subnav that appears in a sidebar on every page but the homepage. The layout should be pretty standard. The site structure is like most:

I) Section Head i) Subpage 1 ii) Subpage 2 iii) Subpage 3 II) Section Head 2 i) Subpage 1 ii) Subpage 2 iii) Subpage 3

What I want is for only the current section to display when on one of the subpages.

I would use the standard Structure nav, but I don’t want the top level to appear as part of a <ul>. That won’t work with the way I’m styling the nav.

Thanks in advance for the help!

Gabriel

       
Jarrett Barnett's avatar
Jarrett Barnett
31 posts
15 years ago
Jarrett Barnett's avatar Jarrett Barnett
Greetings, I) Section Head i) Subpage 1 ii) Subpage 2 iii) Subpage 3 II) Section Head 2 i) Subpage 1 ii) Subpage 2 iii) Subpage 3 What I want is for only the current section to display when on one of the subpages. I would use the standard Structure nav, but I don’t want the top level to appear as part of a <ul>. That won’t work with the way I’m styling the nav. Gabriel

You could try just using the built in structure function:

{exp:structure:nav_sub start_from="/{segment_1}/{segment_2}”}

Note that you may need to add some a condition to check whether your on a section head vs a subpage. Of course, if your pages use separate templates (or separate embeds), that would be easy implementation.

       
Peter Lewis's avatar
Peter Lewis
280 posts
15 years ago
Peter Lewis's avatar Peter Lewis
I) Section Head i) Subpage 1 ii) Subpage 2 iii) Subpage 3 II) Section Head 2 i) Subpage 1 ii) Subpage 2 iii) Subpage 3 What I want is for only the current section to display when on one of the subpages.

The following should build your menu, using h3 for the top level items instead of ul & li, which are only used for the lower level:

{exp:structure_entries depth="2"}
  {if {depth} == 1}{!-- Top Level --}
    <h3>{title}</h3>
    {if {children_total} > 0}{!-- Has Children --}
    <ul{if "{segment_1}" != "{page_url}"} class="hide-menu"{/if}>
    {/if}
  {if:else}{!-- Children --}
        <li>{title}</li>
  {/if}
  {if {last_sibling}}{!-- Last Child - so close markup --}
    </ul><!-- End of level{depth} -->
  {/if}
{/exp:structure_entries}

Then add this CSS:

ul.hide-menu {
    display:none;
}

This assumes that {segment_1} is the url_title from the top level items of your menu.

       
jlundell's avatar
jlundell
18 posts
15 years ago
jlundell's avatar jlundell

At the moment, I’m sort of hacking Structure to give me the effect of a menu with classes ‘here’ and (effectively) ‘ancestor_of_here’. I use it to highlight the path through the menu from the root to the current page.

Is that something that Entries could do, or does it need something analogous to current_page to find parents of current_page?

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

Should be quite straight forward, I’ve added it to the to do list.

       
outline4's avatar
outline4
271 posts
15 years ago
outline4's avatar outline4

hi there, thanks for this plugin! I think it does it’s job perfectly.

there is one thing that I am missing, or that I am not aware of how it can be achieved: I would like to be able to display next and previous entries.

I looked over your variables and coudn’t find anything to achieve this. maybe something like {next_child} or {previous_child} would make sense… or something like: {exp:structure_entries:next_child} {exp:structure_entries:previous_child}?

cheers stefan

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

As structure_entries loops through all the children, not just displaying a specific one, why would you want to display next_child/previous_child?

Edit: Re-reading your post, I understand now - it’s a separate tag you want to output, when you’re showing an individual page. Can’t see the sense in putting it as part of the main entries loop, so will add seperate templates tags for these.

And what would they output? URL? Title?

Could you give an example of what you’re intending to do and I might be able to help you better.

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

I actually second this request: i’d like a next-child/prev-child based on the current page if possible. Because Structure entries DO have an order, and it’s damn difficult to get the prev/next one out of Structure itself.

I’d personally like it to output url and title.

Adrienne

       
outline4's avatar
outline4
271 posts
15 years ago
outline4's avatar outline4
I actually second this request: i’d like a next-child/prev-child based on the current page if possible. I’d personally like it to output url and title.

maybe the entry_id or url_title of the next / prev entries would be helpful aswell… this was a clients request. but I can think of other applications…

maybe someone has a sql queries snippet to share?

cheers stefan

       
First 2 3 4 5 6 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.