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

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

@agun Great solution! Thanks for sharing, I’m sure someone will hit that same issue at some point.

       
Brian M.'s avatar
Brian M.
529 posts
16 years ago
Brian M.'s avatar Brian M.

agun thanks - I’m definitely going to need that!

And thanks rockthenroll for the ongoing support for this great module!

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

Note: several of the issues people have been hitting were environment or tag error related. Not trying to point fingers, just want to make sure everyone knows bugs are being taken seriously and not left open.

       
AJP's avatar
AJP
311 posts
16 years ago
AJP's avatar AJP

These forum threads are way to long, and not a great way for support, but hey, whatever!

I’m sure it’s in there somewhere, but I’d like to request parameters for the navigation functions that let me declare the IDs of the #nav, and #nav_sub that get generated. I’ve edited the module to output classes also, since I repeat the header nav in the footer, and you can’t have two #nav on the same page.

Thanks!

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

@AJP Thanks for the feature note. Not sure well add this in right now, but we appreciate the feedback.

Good point on this being a hard way to deliver support. Anyone is welcomed to start a new thread with their issue and PM me a link, but I can’t really control how people use this, but want to make sure everyone gets the help they need.

       
AJP's avatar
AJP
311 posts
16 years ago
AJP's avatar AJP

Like I said, for me to work around it right now, I just changed line 87 mod.structure.php from

$html = "<ul id=\"nav\">";

to

$html = "<ul class=\"nav\">";

I just noticed that most EE native generating tags and pairs allow you to specify a class or ID (or neither) which then uses your declared ones, or the default (#nav in your case) or might even have no class or id generated. It was a pain on this project to have to change all my 3rd party CSS rules to match the new HTML output by structure, so I’d vote for it if voting matters. 😊

Thanks for the module, it’s hitting a sweet spot right now instead of tons of weblogs for structure, just use this! Bingo!

       
AJP's avatar
AJP
311 posts
16 years ago
AJP's avatar AJP

One more bit. Since I’m using the listing templates for multiple sub-listings. The structure tab, (at least for me) is saving the appropriate listing weblog_id to the database, but doesn’t show the appropriate (no selected=”selected”) in the listing weblog on the structure tab. FYI.

I spent a few minutes trying to figure out where to add the selected clause but started to get lost and just checked the DB to make sure it saved the right one. It does, so we’re ok on that front. Thanks!

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

Hi AJP… I came across the ID issue as well (I use the {main_nav} tag in my header AND in my footer). I have slightly re-written the “main_nav” function to include an “id” attribute… if you don’t use it, then it defaults to “nav”…

function nav_main() {
    global $DB, $IN, $OUT, $PREFS, $TMPL;
    
    if($PREFS->ini('word_separator') == 'dash') {
        $separator = "-";
    } else if ($PREFS->ini('word_separator') == 'underscore') {
        $separator = "_";
    }
    
    // get site ID
    $site_id = $PREFS->ini('site_id');
    // get current uri path
    $uri = $IN->URI;
    
    // set defaults
    $ul_open_id = $TMPL->fetch_param('id');
    $ul_open_id = $ul_open_id ? $ul_open_id : 'nav';
    
    // Limit by weblog(s)
    $where_clause = '';
    if($TMPL->fetch_param('weblog') != '') {
        $weblog_ids = explode(" ", $TMPL->fetch_param('weblog'));
        if($weblog_ids[0] == "not") {
            $weblog_ids = $weblog_ids[1];
            $weblog_not = 'NOT';
        } else {
            $weblog_ids = $weblog_ids[0];
        }
        
        $weblog_ids = explode("|", $weblog_ids);
        $weblog_ids = implode(",", $weblog_ids);
        $where_clause .= " AND node.weblog_id $weblog_not IN ($weblog_ids)";
    }

    
    // Retrieve status labels to exclude
    // break apart string at pipe chars and build array
    $exclude_status = $TMPL->fetch_param('exclude_status');
    $exclude_status_list = split("\|", strtolower($exclude_status));
    
    // get site pages data
    //$site_pages = $PREFS->core_ini['site_pages'];
    $site_pages = $PREFS->ini('site_pages');
    
    // get structure data from DB    
    $sql = "SELECT node.*, 
                expt.title,
                expt.status 
            FROM exp_structure AS node
            INNER JOIN exp_weblog_titles AS expt 
                ON node.entry_id = expt.entry_id
            WHERE node.parent_id = 0 
                AND node.site_id = $site_id
                $where_clause
            GROUP BY node.entry_id 
            ORDER BY node.lft";
    $result = $DB->query($sql);
     
    // Remove anything to be excluded from the results array
    foreach ($result->result as $key => $entry_data) {
        if( in_array( strtolower($entry_data['status']), $exclude_status_list) ) {
            unset($result->result[$key]);
        }
    }
    
    $segment_1 = $IN->fetch_uri_segment('1');

    if ($OUT->out_type == '404') { $page_not_found = true; } else { $page_not_found = false; }
     
    if(count($result->result) > 0) {
        $html = "<ul id=\"$ul_open_id\">";
        $ul_open       = false;
        foreach ($result->result as $entry_data) {
            // out entry uri of this loop instance
            $euri = $site_pages['uris'][$entry_data['entry_id']];
            // current page's parent uri
            $puri = $node['parent_id'] ? $site_pages['uris'][$node['parent_id']] : '';

            $here = '';
            if ($uri === $euri || ($uri == '' && $euri == '/') || $segment_1 === trim($euri, '/') && !$page_not_found ) {
                $here = 'here';
            }
            
            $last = '';
            if($entry_data == end($result->result)) {
                $last = 'last';
                if($here != '') { $last = ' ' . $last; }
            }
        
            // Make sure we have the site_url path in case we're operating in a subdirectory
            // If site_index is set then add it to URIs, otherwise leave it blank
            //$root_uri = parse_url($PREFS->ini('site_url'), PHP_URL_PATH); // req. PHP v5.1.2
            $the_uri = parse_url($PREFS->ini('site_url'));
            $root_uri = $the_uri['path'];
            $index_uri = $PREFS->ini('site_index');
            //$index_uri = $PREFS->ini('site_index') ? "/" . $PREFS->ini('site_index') : "";
            $item_uri =    str_replace('//', '/', $root_uri . $index_uri . $euri);
            
            $html .= "\n<li";
            
            if($here || $last) {
                 $html .= ' class="' . $here . $last . '"';
            }
            
            $html .= ">";
            $html .= "<a >" . $entry_data['title'];
            $html .= "</a></li>";
        }
        
        $html .= $ul_open ? "\n</ul></li></ul>" : "\n</ul>";
        
    }
    //$html .= '<pre>' . $sql . '</pre>

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

Note that this version of the “main_nav” function also includes the “weblog_id” issue I mentioned a couple of pages ago!

So how to use this…

{exp:structure:nav_main id="primary-nav"}

And will output…

<ul id="primay-nav">
<li>...
</ul>

Cheers.

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

Oh… and in regards to this forum topic being so long… I have two thoughts…

  1. This is a free module, so ANY support is MUCH appreciated. I think we can all agree on that! 😉

  2. Maybe when a new version of this module is released, that might be a good time to “split” this thread, and start a new one (with links between the two threads!). Each time a new version is released, a new thread is started.

Thoughts?

       
smit's avatar
smit
7 posts
16 years ago
smit's avatar smit

First let me say that this is a great module. I convinced my boss to use EE for our new website and currently we are in the development stage. Coming from CMS with File/Tree-Structure this module makes the switch easier.

However I have two small suggestions to improve the module:

  1. Better i18n. The language file is far from covering every string used in the module.
  2. Considering the order of the pages in the {exp:weblog:entries}-tag.

Keep up the good work, it’s a great module. 😊

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

@smit Better language support is on our (very long) list. Check your PMs I’d like to hear more about your ordering item.

       
D. Shun-Luoi Fong's avatar
D. Shun-Luoi Fong
75 posts
16 years ago
D. Shun-Luoi Fong's avatar D. Shun-Luoi Fong

Is there a tag to refer directly to the Structure URI without the parent being attached? For example, I have a Structure-managed “About” weblog. For an entry I entered the following info:

Title: History URL Title: our-history Structure URI: organization-history Parent: About Template: about/index

I know I can use {page_uri} and {page_url} to give:

{page_uri} = /about/organization-history {page_url} = http://www.domain.com/about/organization-history

and {url_title} = our-history

I could make URL Title and Structure URI the same and just use {url_title}. But for the sake of argument, if they are different and I want to reference just the label in the Structure URI, is there a tag to do it, i.e. to output: organization-history?

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

@D. Shun-Luoi Fong this s definitely something we’re looking into. It’s come up a few times and there is an issue because url_title isn’t always the same. Hopefully it will make it into an upcoming version.

       
D. Shun-Luoi Fong's avatar
D. Shun-Luoi Fong
75 posts
16 years ago
D. Shun-Luoi Fong's avatar D. Shun-Luoi Fong
@D. Shun-Luoi Fong this s definitely something we’re looking into. It’s come up a few times and there is an issue because url_title isn’t always the same. Hopefully it will make it into an upcoming version.

Sounds good. For now I guess I will just ensure that the url_title is always the same and use that. Thanks for the update.

       
D. Shun-Luoi Fong's avatar
D. Shun-Luoi Fong
75 posts
16 years ago
D. Shun-Luoi Fong's avatar D. Shun-Luoi Fong

A suggestion for a feature, perhaps someone has already mentioned this…

It would be nice if, in the tree sitemap view, you can collapse sections so that you don’t have to scroll as far. Not a big deal if there aren’t many pages in your site, but for my particular situation it is already getting long. For example, I have one top level section that has 25 (and growing) subsections/subpages. It would be great if I could collapse sections to see only the top level link, or even collapse a subsection to see the top level link and second level links, but not 3rd, 4th, etc. levels.

       
First 29 30 31 32 33 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.