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

wuwongy's avatar
wuwongy
10 posts
16 years ago
wuwongy's avatar wuwongy

@travis - This is really an amazing module its come just in the nick of time for a projects I’m on. Thanks again! 😊

Now, my php skills aren’t really my strong point (more of a front end developer) but I had similar needs to what Michael is requesting (ie a top-level items nav) and managed to make a new function out of your nav_sub in mod_structure.php for a top level nav with drop-down to second level. So I can add {exp:structure:nav_main} to get a list with children.

Would you like to see if this is useful for you to add for others to use?

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

@wuwongy that may be in a future version, but not needed right now. Generally top level pages are in a template or don’t need to be dynamic. Maybe someday! Feel free to use your update though. Thanks!

       
Blis Web Agency's avatar
Blis Web Agency
67 posts
16 years ago
Blis Web Agency's avatar Blis Web Agency

Wuwongy I’d love to see how you created the top level nav with a drop down to the second level items. Could you post the code?

       
Gabriel's avatar
Gabriel
130 posts
16 years ago
Gabriel's avatar Gabriel

@rockthenroll: This is a great module. Thanks!

I’ve got little feature request important for a no-english websites. Could you move all interface phrases to the language file?

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

@Gabriel adding to our wishlist. Can’t guarantee a timeframe though 😊

       
wuwongy's avatar
wuwongy
10 posts
16 years ago
wuwongy's avatar wuwongy

@blis

Here you go… like I say PHP ain’t my strong point so this can probably be improved. But I managed to make this out of the nav_sub function.

Paste into mod_structure.php then just add - {exp:structure:nav_main} to your templates.

Hope this helps 😊

function nav_main() {
    global $DB, $IN, $PREFS;
    
    // get site pages data
    $site_pages = $PREFS->core_ini['site_pages'];
    // get current uri path
    $uri = $IN->URI;
    // get current entry id
    $entry_id = array_search($uri, $site_pages['uris']);
    // get node of the current entry
    
    $sql = "SELECT *
            FROM exp_structure AS node
            INNER JOIN exp_structure AS parent 
                ON node.lft BETWEEN parent.lft AND parent.rgt 
            INNER JOIN exp_weblog_titles AS expt 
                ON node.entry_id = expt.entry_id
            WHERE node.parent_id = 0 
            GROUP BY node.entry_id 
            ORDER BY node.lft";
    $result = $DB->query($sql);

    $html = '<ul id="nav">';
    foreach ($result->result as $top) {
        // get children
        $childsql = "SELECT *
            FROM exp_structure AS node
            INNER JOIN exp_structure AS parent 
                ON node.lft BETWEEN parent.lft AND parent.rgt 
            INNER JOIN exp_weblog_titles AS expt 
                ON node.entry_id = expt.entry_id
            WHERE node.parent_id = " .$top['entry_id'] ."
            GROUP BY node.entry_id 
            ORDER BY node.lft";
            $childresult = $DB->query($childsql);
    
        // out entry uri of this loop instance
        $euri = $site_pages['uris'][$top['entry_id']];

        $html .= '<li>';
        $html .= '<a href="http://{path=/">' . $top['title'];_        $html .= '</a>';
        if ($childresult ->num_rows > 0){
        $html .= '<ul>';
        foreach ($childresult->result as $child) {
        $childuri = $site_pages['uris'][$child['entry_id']];

        $html .= '<li><a href="{path=/' . $childuri . '}">' . $child['title'] .  '</li>';
        }
        $html .= '</ul>';
        }
        $html .= '</li>';

    }
    $html .= '</ul>';
    //$html .= '<pre>' . $childsql . '</pre>

<p>’;
    return $html;
}
</pre>

       
wuwongy's avatar
wuwongy
10 posts
16 years ago
wuwongy's avatar wuwongy

Has anyone had any joy getting weblog pagination to work with this module installed? I notice the module requires dynamic=”off” which I think stops pagination working.

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

Pagination currently doesn’t work with the module because we’re assigning exact URLs to entries, so pagination can’t find itself (if that makes sense). On the wishlist. Also, you don’t need dynamic=”off” or it may not work. You only need dynamic=”off” when calling a listing or single entry NOT related to the “page” you’re on.

       
wuwongy's avatar
wuwongy
10 posts
16 years ago
wuwongy's avatar wuwongy

Ok, thanks Travis!

       
Jason Morehead's avatar
Jason Morehead
454 posts
16 years ago
Jason Morehead's avatar Jason Morehead

This looks fantastic, and just in time, too. I just started working on a site for which this might be a godsend.

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

@opuszine Awesome! Let me know what you think!

       
Jason Morehead's avatar
Jason Morehead
454 posts
16 years ago
Jason Morehead's avatar Jason Morehead

I’ve just started using it, and so far, I’m really impressed. But I’ve run into one issue that I can’t quite seem to work out.

I have created a weblog entitled “pages” that holds all of my site’s static pages. I’ve created an entry – “Ministries” – that will serve as the “parent” page of the “Ministries” section, and I’ve created several “children” entries – e.g., “Worship”, “Children” – that will be “sub” pages of “Ministries”.

So far, so good. However, I have all of these static pages using a single template. Which means that, when I attempt to pull up “Ministries” or any of its children, I don’t get just that particular entry, I get a list of all of the entries in the “pages” weblog. Which, obviously, isn’t right.

So, what am I doing wrong? Is there some configuration setting I missed?

       
Jason Morehead's avatar
Jason Morehead
454 posts
16 years ago
Jason Morehead's avatar Jason Morehead

Oh, and here’s one for the feature request list. It’d be nice to be able to display a list of particular entry’s children, if any, and even limit it to display a specific number of levels of children, if any.

       
Jason Morehead's avatar
Jason Morehead
454 posts
16 years ago
Jason Morehead's avatar Jason Morehead

Re: my earlier issue, I figured out what was going on. I misread the documentation and had dynamic=”off” in my {exp:weblog:entries} tag. I took that out, and everything seems to be working fine now.

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

@opuszine glad you got it figured out. Just when I came in to answer!

RE: the dispay children tag. The only tag to do that sort of thing would be

{exp:structure:nav_sub}

and that’s only for sub navigation. EE tags should work for everything else.

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