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

New Module: Structure - Uses entries to create a page hierarchy for static and listing pages

Development and Programming

Mr. Wilson's avatar
Mr. Wilson
131 posts
16 years ago
Mr. Wilson's avatar Mr. Wilson
I am having a problem with pagination. When I click the next button, the URL changes properly, but my list doesn’t show the next batch of items. I did find, however that if I add index.php directly after the site_url, it works (i.e. www.mysite.com/index.php/news/?page=2).

We had the same problem. Here’s how we fixed it:

Very near the top of the paginate() method in mod.structure.php is

$current_page = $IN->GBL('page', 'GET') ? $IN->GBL('page', 'GET') : 1;

We replaced that line with

<pre><code>//$current_page = $IN->GBL(‘page’, ‘GET’) ? $IN->GBL(‘page’, ‘GET’) : 1;

// Begin hack
$current_page = 1;
$uri = explode('/', $_SERVER['REQUEST_URI']);
if ($segment = $TMPL->fetch_param('page_segment') && isset($uri[$segment]))
{
    $current_page = substr($uri[$segment], 6);
}
else
{
    foreach ($uri as $seg => $val)
    {
        if (strstr($val, '?page='))
        {
            $current_page = substr($val, 6);
            break;
        }
    }
}
if (! is_numeric($current_page) OR ! is_int($current_page * 1) OR $current_page < 1) $current_page = 1;
// End hack[/code]

Note that the hack allows you to specify the uri segment of the ?page= value via a page_segment=”” parameter (i.e. page_segment=”3”), or you can just let ‘er fly and it will attempt to figure it out on its own. If any of a few simple checks fail, the page number is set to 1.

       
Wayde Christie's avatar
Wayde Christie
24 posts
16 years ago
Wayde Christie's avatar Wayde Christie

Hey Travis,

Trying to get pagination working with structure and it aint happening.

Structure page content and weblogs are being displayed - just no pagination.

Here’s my template code:

{assign_variable:this_page_weblog="pages"}
{assign_variable:this_index_weblog="blog"}
 
{exp:weblog:entries
    _cache="yes"
    disable="category_fields|member_data|pagination|trackbacks"
    refresh="60"
    rdf="off"
    weblog="{this_page_weblog}"
    url_title="blog"
}
    {if no_results}{redirect="404"}{/if}
    {embed="_includes/.head"
        body_class="three-col"
        entry_id="{entry_id}"
    }

            <div id="content">
                <div class="copy">
                    {title}
{/exp:weblog:entries}
                    {exp:structure:paginate parse="inward"}
                    <ol class="index hfeed">
                        {exp:weblog:entries
                            weblog="blog"
                            rdf="off"
                            limit="1"
                            disable="category_fields|member_data|trackbacks"
                            status="not closed"
                            dynamic="off"
                        }
                        <li class="entry" id="post-{entry_id}">
                            {exp:smarty_pants}
                            <h1 class="sifr entry-title{if count == 1} page-title{/if}"><a href="/blog/post/{comment_entry_id_auto_path}{url_title}/">{title}</a></h1>
                            <div class="post-info"><address class="author">{author}</address> – <abbr title="UTF Date">{entry_date format="%j%S %F, %Y"}</abbr> <a href="/blog/post/{comment_entry_id_auto_path}{url_title}/#comments%22class=%22comments-total" title="Comment on this entry" class="comments-total">{comment_total} Comment{if {comment_total} != 1}s{/if}</a></div>
                            {blog-body}
                            {/exp:smarty_pants}
                            
                                <a href="/blog/post/{comment_entry_id_auto_path}{url_title}/#commentclass=leave-comment">Leave a comment ›</a>
                                <strong>Posted in:</strong>
                                {categories backspace="1"}<a href="/blog/category/{category_url_title}/" rel="tag" title="Browse {category_name}">{category_name}</a>, {/categories}
                            
                        </li>
                        {/exp:weblog:entries}
                    </ol>
                    {/exp:structure:paginate}
                </div>
                <div class="sub-copy">
                    {embed="_includes/.page-utils" title="{title}" page_url="{page_url}"}
                    {embed="blog/.sidebar"}
                </div>
            </div>
{embed="_includes/.foot"}

So the first loop churns out the structure page, the second displays blog entries.

Cheers.

       
rick.prince's avatar
rick.prince
111 posts
16 years ago
rick.prince's avatar rick.prince

Is there a way to hide nav_sub if no children are shown for the current url? I remember there being a conditional in the docs, but I think it’s been removed. Anyone have an idea?

       
dix-eaton's avatar
dix-eaton
5 posts
16 years ago
dix-eaton's avatar dix-eaton

I’m having issues with pages using the correct templates. The first root level page, along with all of its children, will use the correct template (site/content), but every subsequent page is using a different template (site/index), despite the settings and structure tab within the entry’s edit screen displaying the correct template is selected (site/content).

Also, if I move the faulty template page to be a child of the correctly templated parent, the faulty page will use the correct template.

Any one run into this before? Or am I missing something obvious? (Which is entirely possible)

       
mediasauce's avatar
mediasauce
14 posts
16 years ago
mediasauce's avatar mediasauce

UPDATE:

I was staging the site at 1and1.com on a basic LAMP package. 1and1 does not support PATH_INFO, so I made the modifications to Structure suggested here: http://ellislab.com/forums/viewreply/604591/.

I also changed my .htaccess file to:

RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    # Administration URL rewriting.
    RewriteRule ^admin(.*)$ admin/index.php?$1 [L,QSA]

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?/$1 [L]

I’ve yet to come across anything this change has broken. I’ll update this post if I happen to find anything.

===============================

I’m attempting to use {exp:structure:paginate} to allow for pagination. This tag uses a query string variable to track the current page, but any time I click a pagination link EE attempts to go to that page and returns a 404 error. I believe this has to do with my .htaccess file, but I’m having trouble finding a work around. Is anyone else willing to share their work around for this? Thanks for any help!

The .htaccess code is as follows: <pre><code> RewriteEngine On RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

# Administration URL rewriting.
RewriteRule ^admin(.*)$ admin/index.php?$1 [L,QSA]

# redirect for sitemap.php
RewriteRule ^sitemap\.xml /sitemap.php [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

# Main URL rewriting.
RewriteRule ^(.*)$ index.php?$1 [L,QSA][/code]
       
patrick-vibes's avatar
patrick-vibes
63 posts
16 years ago
patrick-vibes's avatar patrick-vibes

I am using structure for a cleint site, it’s great so far as I have setup all the parent and children pages etc, I was originally using wordpress for it’s ease of doing this but switched to EE after finding this module.

One issue I am having is trying to style the nav_sub - it’s a nightmare at the moment as I can style all the children but I want to style the parent sub_level_0 differently but can not do it without it effecting the children and I think it is because the output for sub_nav is not closing off an list tag, see my code below:

<ul id="nav_sub"><li class="sub_level_0 parent_here"><a href="/practice/pre-entry/">Pre-Entry</a>
<ul>
<li class="sub_level_1 here"><a href="/practice/pre-entry/working_with_parents/">Working with Parents</a></li>
<li class="sub_level_1"><a href="/practice/pre-entry/financial_support/">Financial Support</a></li>
<li class="sub_level_1"><a href="/practice/pre-entry/mentoring_and_shadowing/">Mentoring and Shadowing</a></li>
<li class="sub_level_1"><a href="/practice/pre-entry/attainment_raising/">Attainment Raising</a></li>
<li class="sub_level_1"><a href="/practice/pre-entry/summer_schools/">Summer Schools</a></li>
<li class="sub_level_1 last"><a href="/practice/pre-entry/art_music_sporting_activities/">Art Music Sporting Activities</a></li>
</ul>
</ul>

the first line opens the unordered list and the parent list tag but it is not closing it anywhere - yet still no validation errors which I would have expected.

I read in this thread that you changed the nesting after a suggestion was made by another member who’s issue was with styling the list.

Can anyone please show an live example of their nav_sub and their css code if they have styled the list so I can see where I am going wrong, I keep trying to style the cascade but no joy.

       
rick.prince's avatar
rick.prince
111 posts
16 years ago
rick.prince's avatar rick.prince

patrick-vibes, Just tested your code and this css works for me.

/* Level 0 - Parents */
ul#nav_sub li a {color: green;}
/* or */
ul#nav_sub li.sub_level_0 a {padding: 10px;}

/* Level 1 - Children */
ul#nav_sub li ul li a {color: red; }
/* or  */
ul#nav_sub li ul li.sub_level_1 a {padding: 0;}

Is your css targeting elements like <li>’s rather than <a>’s?

       
rockthenroll's avatar
rockthenroll
485 posts
16 years ago
rockthenroll's avatar rockthenroll

Ok, getting back into things. I’ll be sending support PMs over the next few days to everyone, a few at a time. Email me travis [at] rockthenroll.com if I miss you or don’t hit you up first.

THE DOCS HAVE MOVED: http://buildwithstructure.com

Changes in 1.3.0

• Bug fix: random page re-ordering • Bug fix: nav_sub li closing bug fix • Tab template now uses language file • NSM Publish Plus support • Preview / Quicksave support • Restyled tab and Structure CP • {exp:structure:nav_main} new parameter: “include” • {exp:structure:nav_main} new parameter: “exclude” • {exp:structure:nav_main} new parameter: “current_class” • {exp:structure:nav_main} new parameter: “include_ul” • {exp:structure:nav_main} new parameter: “css_id” • {exp:structure:nav_main} new parameter: “css_class”

Many updates to this version were submitted by: Leevi Graham Thanks, Leevi!

       
Andrew Gunstone's avatar
Andrew Gunstone
101 posts
16 years ago
Andrew Gunstone's avatar Andrew Gunstone

Thank you, thank you, thank you. This new version certainly takes Structure to a new level. The inclusion of the “css_id” parameter in “nav_main” is great. As I normally use my main navigation at both the header and footer of a page (and using the same ID in two places doesn’t validate), I kept having to hack the code to include this parameter myself!

One thing I would love to see in 1.3.1 is the inclusion of a “weblog” parameter in the “nav_main”. I often have 2 or more weblogs that are set to “structure”… but only one of them needs to be included in the main navigation.

Fantastic work. Thanks again.

       
Andrew Gunstone's avatar
Andrew Gunstone
101 posts
16 years ago
Andrew Gunstone's avatar Andrew Gunstone

Hi again. Found a small bug in “{exp:structure:nav_main}”…

The new documentation says:

{exp:structure:nav_main} new parameter: "css_id"
{exp:structure:nav_main} new parameter: "css_class"

where the actual code is looking for:

{exp:structure:nav_main} new parameter: "nav_id"
{exp:structure:nav_main} new parameter: "nav_class"

Cheers

😊

       
Ian Beck's avatar
Ian Beck
76 posts
16 years ago
Ian Beck's avatar Ian Beck

Hey there,

I was trying to use Structure on a site under development, and kept getting “ERROR” whenever I tried to drag and drop pages in the list. A little detective work revealed that this was because Structure was calling index.php for the Ajax, when I’d renamed my index.php file so I could test the site next to the live site.

If there’s any way to auto-detect the index file, that’d be nice. Now I know what’s going on I can load up Firefox and run the links by hand if need be until the site is launched, but it would be nice to support for future confused users. 😊

       
ipixel (Australia)'s avatar
ipixel (Australia)
158 posts
16 years ago
ipixel (Australia)'s avatar ipixel (Australia)

Hi Travis

First up, the Structure module is tops. One of the defaults on all my client sites.

Just a couple of things that I’d love to see added in a future version to assist in the management of content. I a lot of my sites, I use weblogs more as content types than as a way of structuring. What I usually do is have a base weblog that the majority of static content pages belong to, then have a set of weblogs for each different type of content such as Team Member Profile, Case Study, Product, Partner etc. Each of these have a different set of fields I need to capture and in most cases a different page template.

What I’d like to see on the Structure CP, is when a user hits ‘Add Page’, they’re given a drop down to choose a specific weblog they want to publish at that point in the hierarchy. It can be done now manually by hitting ‘Publish’, choosing the weblog (ie. type of content) you want to use then in the ‘Structure’ tab selecting its parent.

I suppose an extension to this could be to allow a super user admin to be able to configure (maybe via a small settings pop next to ‘Add Page’) what type of content you would normally allow to be published there.

I’d definitely start paying for each site I installed Structure on similar to Playa, if such features were added on. Keep up the good work.

Cheers Brendan

       
Andrew Gunstone's avatar
Andrew Gunstone
101 posts
16 years ago
Andrew Gunstone's avatar Andrew Gunstone

In reply to Wayde Christie - and your pagination issue… I am having the same problem. The issue is the way you are listing out your {exp:weblog:entries} tag.

This will NOT work:

{exp:structure:paginate parse="inward"}
    <ol class="index hfeed">
    {exp:weblog:entries
        weblog="blog"
        rdf="off"
        limit="1"
        disable="category_fields|member_data|trackbacks"
        status="not closed"
        dynamic="off"
    }
        <li class="entry" id="post-{entry_id}">
        ....
        </li>
    {/exp:weblog:entries}
    </ol>
{/exp:structure:paginate}

If you collapse your {exp:structure:paginate} tag, then it DOES work:

{exp:structure:paginate parse="inward"}
    <ol class="index hfeed">
    {exp:weblog:entries weblog="blog" rdf="off" limit="1" disable="category_fields|member_data|trackbacks" status="not closed" dynamic="off"}
        <li class="entry" id="post-{entry_id}">
        ....
        </li>
    {/exp:weblog:entries}
    </ol>
{/exp:structure:paginate}

The issue is that the “paginate” function doesn’t find the {exp:structure:paginate} tag when it has hard-returns in it. You need to have the tag all on one line.

Maybe you could lean over your desk and tap Leevi on the shoulder to help us fix this? I just don’t know enough about PHP regular expressions to know how to fix the issue.

       
Andrew Gunstone's avatar
Andrew Gunstone
101 posts
16 years ago
Andrew Gunstone's avatar Andrew Gunstone

Bit of a followup to my above post… this issue seems to be more with the EE array “$TMPL->var_pair” and NOT with the Structure code.

       
ipixel (Australia)'s avatar
ipixel (Australia)
158 posts
16 years ago
ipixel (Australia)'s avatar ipixel (Australia)

In regards to the “show_overview_link=”yes” option, is it normal for it to be tagged with the “here” class even though you’re not on that page?

I have the “here” class styled differently from the rest of the links, so it looks like the user is on two pages at once.

Cheers Brendan

       
First 46 47 48 49 50 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.