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

Nathan Pitman's avatar
Nathan Pitman
531 posts
15 years ago
Nathan Pitman's avatar Nathan Pitman

Hi Travis. Thanks for the prompt reply. I’ve not seen the problem myself - was just nervous as it had been raised. Hopefully it’s a non issue then. 😊

       
emagine media's avatar
emagine media
65 posts
15 years ago
emagine media's avatar emagine media

Have a funny one and I haven’t seen any reference to it in this long thread.

I have two sites, in msm, and then 2 languages for the second site.

Site 1 uses structure with no prob for a lower nav with this url layout:

.url/about .url/about/who-we-are

Site 2 uses the same, except the language version is in there in segment_1, which is my template group:

.url/en/about .url/fr/about

using this code, I can’t seem to figure out how to get the url segment_1 in there, to preserve my language version?

{exp:structure:nav_sub start_from="/about" show_level_classes="no" limit_depth="1"}

All i want to do is have a sub-nav of the links like this, dpeending on which language I am in:

.url/en/about/who-we-are .url/fr/about/who-we-are

Any ideas? Or even possible?

Even if I could set my structure url in my top level page to

/en/about

then put my next page, who-we-are as a child, then call this code:

{exp:structure:nav_sub start_from="/en/about-us" show_level_classes="no" limit_depth="2"}

Looking at this a bit, and seeing if a some hacking can be done. Am a bit out of my depth, but was looking at this: (about line 746 of mod.structure.php. I know it is completely wrong, but could it be adjusted here to prepend the segment, or whatever I want?

// Make sure we have the site_url path in case we're operating in a subdirectory
        $the_uri = parse_url($PREFS->ini('site_url'));
        $root_uri = $the_uri['path'];
        $index_uri = $PREFS->ini('site_index');
        $segment_1 = $PREFS->ini('segment_1');
        $item_uri =    str_replace('//', '/', $root_uri . $segment_1 . $index_uri . $page_uri);

OR an option to prepend, like this?

{exp:structure:nav_sub start_from="/about-us" prepend="/en" show_level_classes="no" limit_depth="2"}

</code></pre>

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

Feature Request:

It would be REALLY nice if i didn’t have to deal with frigging serialized arrays just to grab the page_uri of one entry. Could you maybe give some thought to adding a page_uri column to the exp_structure table? You wouldn’t need the whole URL in there (after all, the table contains parent info), just the last segment part.

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

What is the reason for having Structure Page URL in addition to EE’s URL Title?

I’ve recently deployed a site with Structure, and the client loves it, but every now and then things break when the two fields aren’t the same. This happens when they create two entries with the title “Monthly Meeting”. The first gets the URL Title of “monthly-meeting” and the second gets “monthly-meeting1”. But Structure’s Page URL doesn’t get the 1 appended to it, which causes problems.

I’m sure this was intentional but I’m not grasping some basic use case for having two fields that have to match. When would you want them to be different?

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

@emagine media - currently not possible as all pages work off exact URLs. You would need to replicate the site under each language as a page.

Example:

/en/about/ /en/about/history /en/work

/fr/about/ /fr/about/history /fr/work

@Adrienne Thanks for the feedback!

@mikec964 They can be called for different reasons or to putout data in different ways. We didn’t want to disable native functionality. If you don’t’ want to use or see url-title, you can hide it through the weblgo prefs.

       
aimelise's avatar
aimelise
31 posts
15 years ago
aimelise's avatar aimelise

My work-in-progress is at http://gsis.amystoddard.com. I’m on the Jamboree Tutorial where it reads:


Click the title for the page “News” Under the structure tab modify the template dropdown to use the template “site/news” Check the box next to “Listing” and select the “News” weblog from the dropdown Click “Update” to save the entry Go to Modules > Structure


My install doesn’t show a box to “Check the box next to “Listing”…” I love how the “add/edit” listings just like this. W/O that, all the news entries appear underneath it.

I have some screen grabs:

Structure Tree:

Structure Tab:

Structure Config:

Travis, you’ve been such a help. Any idea how I can fix this? I’m running 1.6.8.

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

@aimelise It’s referring to creating that listing, which you need to have an extra weblog for. Listings need their own weblog, so once you create a News weblog and assign it to be managed by Structure (under settings), you’ll see the listing checkbox appear when editing the news page. Email me if you need more help.

       
jtnick's avatar
jtnick
29 posts
15 years ago
jtnick's avatar jtnick

Just getting started with this extension. Looks promising.

I’ve run into a small snag. For some reason, i can not get the “css_id” or the “css_class” tags update the properties of the main <ul>.

Any ideas why this may be? My code looks like the following:

{exp:structure:nav_main current_class="current" exclude_status="standalone|closed|pending" css_id="navigation"}

setting css_id = navigation does nothing changing this to css_id = navigation does nothing as well.

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

@misterKeebles try nav_id and nav_class, sorry the docs are mismarked…

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

Hi all,

I had a bit of a need to create a simple “Next/Previous Entry” type thing for use with some News pages that I had listed under the Structure module. The problem with the built in EE next/previous entry is that you couldn’t use the {page_url} variable.

So I have created a little function that helps with that. Basically what it is good for is when you have setup something like a News weblog to sit as a listing weblog under the News page.

To use it, simple open /system/modules/structure/mod.structure.php and copy and paste this function somewhere.

function entry_linking() {
    global $DB, $IN, $PREFS, $TMPL, $FNS;
    
    $html = "";
    $html = ( ! $TMPL->tagdata) ? '' :  $TMPL->tagdata;

    $site_pages = $PREFS->ini('site_pages');
    
    if (strtolower( $TMPL->fetch_param('type') ) == "next") $type = "ASC";
    elseif (strtolower( $TMPL->fetch_param('type') ) == "previous") $type = "DESC";
    else return "";
    
    $uri = $TMPL->fetch_param('uri');
    $uri = $uri ? $uri : $IN->URI;
    
    $entry_id = array_search($uri, $site_pages['uris']);
    $node = $entry_id ? $this->nset->getNode($entry_id) : false;
    
    // node does not have any structure data we return nothing to prevent errors
    if ($node === false && ! $entry_id) {
        return '';
    }
    
    // if we have an entry id but no node, we have listing entry
    if ($entry_id && ! $node) {
        $pid = $this->get_pid_for_listing_entry($entry_id);

        // get node of parent entry
        $node = $this->nset->getNode($pid);
    }

    $weblog_id = $node['listing_wid'];
    
    $sql = "SELECT entry_id, title 
            FROM `exp_weblog_titles` 
            WHERE weblog_id = $weblog_id
                AND status = 'open' 
            ORDER BY entry_date $type";

    $result = $DB->query($sql);
    
    $count = 0;
    $r_id = 0;
    if ($result->num_rows > 0) {
        foreach($result->result AS $row)
        {
            if ($row['entry_id'] == $entry_id) $r_id = $count+1;
            $count++;
        }
    }
    if ($result->result[$r_id]['title'] != "")
    {
        $row['linking_title'] = $result->result[$r_id]['title'];
        $row['linking_page_url'] = $site_pages['uris'][$result->result[$r_id]['entry_id']];
    }
    else
    {
        return "";
    }
        
    foreach ($TMPL->var_single as $key => $val)
    {
        if (isset($row[$val]))
        {
            $html = $TMPL->swap_var_single($val, $row[$val], $html);
        }
    }

    return $html;
    
}

It is pretty easy to use it from there… on the News “article” page (i.e. not the listing page), you can add the next and back links anywhere. The function takes the current page URL, looks to see if it belongs somewhere in Structure, then grabs the next and previous entries. If they are not found, then it will return empty.

{exp:structure:entry_linking type="next"}<a href="http://{linking_page_url}">« {linking_title}</a>{/exp:structure:entry_linking}

{exp:structure:entry_linking type="previous"}<a href="http://{linking_page_url}">{linking_title}</a> »{/exp:structure:entry_linking}

There are no guarantees with this! It seems to work fine for me. Hopefully someone else will find it useful as well.

Long live Structure!

😉

Cheers

Andrew.

       
aimelise's avatar
aimelise
31 posts
15 years ago
aimelise's avatar aimelise

I’m having pagination issues in 1.6.8.

My example page here should only show two entries, then paginate to the next one. http://gsis.amystoddard.com/about/staff-directory/

The page domain changes, but the content stays the same. http://gsis.amystoddard.com/about/staff-directory/?page=2

My template snippet for the template group “staff-directory/index” looks like this:

{exp:structure:paginate parse="inward" first="« First" next="Next »" last="Last »" show_first_last="no"}
    {exp:weblog:entries weblog="staff-directory" dynamic="off" limit="2"}
    <div class="item">
    <h3><a href="http://{page_url}">{staff-first-name} {staff-last-name}</a></h3>
        {staff-title}
        {staff-phone1}
    </div>
    {/exp:weblog:entries}
{/exp:structure:paginate}

I read a thread here, but this .htaccess mod doesn’t work for me. http://ellislab.com/forums/viewreply/641072/

Can I get some advice how to fix this?

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

@agun Thanks for the code that’s handy!

@aimelise I’m emailing you separate as this is most likely the htaccess file and will be specific to your server.

       
Matthew Lanham's avatar
Matthew Lanham
145 posts
15 years ago
Matthew Lanham's avatar Matthew Lanham

I was wondering if anyone had used Structure with the Search module, the standard link variables like {url_title} or {auto_path} are not creating the correct website address to the page within structure.

It picks up the url title of that page but not the url structure before, so for 2nd level pages it brings the content in but does not highlight the link on the left nor bring in the correct template.

Any ideas?

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

@Matthew You need to use {page_uri} or {page_url} since you’re not using standard templating via Structure

       
Matthew Lanham's avatar
Matthew Lanham
145 posts
15 years ago
Matthew Lanham's avatar Matthew Lanham

I think that solved it, seems some are not showing any URL, and other are showing the correct URL, very odd.. i am using {page_url}

       
First 65 66 67 68 69 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.