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

We haven’t been authorized to launch a few that are using it client-wise yet. The demo installs we’ve been testing on are really a mess at this point from some other module testing. I’m looking into doing a few screencasts soon. Keep an eye out!

       
Joe Wolin's avatar
Joe Wolin
206 posts
16 years ago
Joe Wolin's avatar Joe Wolin

What’s your vision for this module with regards to the 2.0 release? I was really hoping 2.0 would support this exact sort of feature (something to break out of the templateGroup/template) mold, but after watching the 2.0 screen casts, it doesn’t appear to offer any huge paradigm changes.

I’m looking forward to seeing your screen casts…

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

We’ll be updating the module for 2.0. The timeline will be determined by the functionality that pops up and any changes we want to make at that time.

       
frenzal's avatar
frenzal
136 posts
16 years ago
frenzal's avatar frenzal

I needed a function similar to nav_sub but for the entire page structure. I’ve made a new function based on the nav_sub function. It expects your homepage to have / as structure URI with {exp:structure:nav_main} you can generate nested UL’s, put the code in mod.structure.php

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("/", $site_pages['uris']);
    // get node of the current entry
    $node = 0; //$start_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) {
        // get entry's parent id
        $pid = $this->get_pid_for_listing_entry($entry_id);
        
        // get node of parent entry
        // because we will be showing nav sub from its view point
        $node = $start_node = $this->nset->getNode($pid);
    }
        
    // if we are on a root that is a leaf
    // no sub nav to return
    if ($node && $node['isLeaf'] && $node['depth'] == 0) {
        return '';
    }
    
    if ($node['isLeaf'] && $node['depth'] > 1) {
        // we are on a child leaf past the root level
        // so we use the parent as the starting point for the sub nav
        $start_node = $this->nset->getNode($node['parent_id']);
    }
    //print_r($start_node);die;
    
    // get siblings
    $where = 'node.parent_id = ' . ($start_node['depth'] ? $start_node['parent_id'] : $start_node['id']);
    // get children
    $where .= ' OR node.parent_id = ' . $start_node['id'];
    
    $entry_depth = $start_node['depth'] ? $start_node['depth'] : 1;
    
    // get structure data from DB            
    $sql = "SELECT node.*, 
                (COUNT(parent.entry_id) - 1) AS depth, 
                ((COUNT(parent.entry_id) - 1) - $entry_depth) AS subDepth, 
                if((node.rgt - node.lft) = 1,1,0) AS isLeaf, 
                expt.title 
            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 parent.lft > 1 
            GROUP BY node.entry_id 
            ORDER BY node.lft";
    $result = $DB->query($sql);
    
    // check how many entries at subDepth 0
    $num = 0;
    foreach ($result->result as $entry) {
        if ($entry['subDepth'] == 0) {
            $num++;
        }
    }
    // if we only have 1 subDepth 0 entry and it has children
    // then we just show the children
    if ($num === 1 && $result->num_rows > 1) {
        unset($result->result[0]);
        foreach ($result->result as &$entry) {
            $entry['subDepth'] -= 1;
        }
    }
    
        $html = '<ul id="nav_main">';
    $prev_subDepth = false;
    $ul_open       = false;
    $i= 0;
    foreach ($result->result as $entry) {    
        if($prev_subDepth == $entry["subDepth"]  AND $prev_subDepth != false){
            $html .= "</li>";
        }
        
        if($entry["subDepth"]  > $prev_subDepth  and $i >0){
            $html .= '<ul>';
        }
        
        if($entry["subDepth"]  < $prev_subDepth  and $i >0){
            $x = $prev_subDepth - $entry["subDepth"];
            for($y=0;$y<$x;$y++){
                $html .= '</li></ul>';
            }
        }
        
        // out entry uri of this loop instance
        $euri = $site_pages['uris'][$entry['entry_id']];
        // current page's parent uri
        $puri = $node['parent_id'] ? $site_pages['uris'][$node['parent_id']] : '';
        
        $here = '';
        if ($euri === $puri) {
            $here = ' parent_here';
        } else if ($uri === $euri) {
            $here = ' here';
        }
        
        $html .= '<li class="sub_level_' . $entry['subDepth'] . $here . '">';
        $html .= '<a href="http://">' . $entry['title'];_        $html .= '</a>';
        
        $prev_subDepth = (int)$entry['subDepth'];
        $i++;
    }
    $html .= '</ul>';
    //$html .= '<pre>' . $sql . '</pre>

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

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

Nice frenzal! Thanks for sharing. We’ll keep this in mind with new updates.

       
RJB's avatar
RJB
35 posts
16 years ago
RJB's avatar RJB

I’m trying to get Structure v1.0.1 running on a Plesk 8.2.1 (dv) 3.0 server at Media Temple running PHP 5.2.3 as a binary CGI.

ExpressionEngine works fine, but when trying to enable the Structure extension at CP Home > Admin > Utilities > Extensions Manager, I get the following error message:

Warning: Cannot modify header information - headers already sent by (output started at /path/to/system/extensions/ext.structure_ext.php:1) in /path/to/system/core/core.functions.php on line 296

Since I can’t continue, I hit the back button in my browser and the Extension shows that it’s somehow enabled despite the error!

Oddly, I’m able to access the Structure module/settings and create a new page from the Publish menu, but when submitting the entry the same error message appears. From my research, the error message does not appear if you click “Quick Save” — only when you submit the entry by clicking “Update”.

It seems like the information is being saved to the database, but something I can’t determine is causing the PHP header errors. Is anyone else using Structure with PHP 5 as a CGI and getting these errors? I’m running ExpressionEngine 1.6.4 (20080829) from a fresh installation.

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

Haven’t seen that particular instance. We’ll look into it, but it may be difficult without that exact setup.

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

I’m testing this awesome module. On my localhost server everything works well. On my live server can’t load jQuery file. As I analyze source code, there is missing following part of code:

<s*cript type="text/javascript" src="http://website-domain/system/lib/jquery-1.2.6.js"></s*cript>

So AXAJ functionality doesn’t work for me. Could you help me anybody localize the problem?

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

@Gabriel do you have the reference correct in the extension settings? For where you have ti placed it should say “/lib/jquery-1.2.6.js”

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

The link to jQuery file is set right. I’m using the same settings as on localhost server. I’m trying install Structure on other website with the same unsuccessful result. The JS part of code still missing.

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

@Gabriel can you PM me a login? I’m leaving pretty soon if you can do it ASAP that would rule. Otherwise, it will have to wait until tomorrow.

       
Jason Morehead's avatar
Jason Morehead
454 posts
16 years ago
Jason Morehead's avatar Jason Morehead
Quick question about the navigation tags.. is there (going to be) any other params that can be used? Such as a way to generate the list for the top-level items as well (not just the child items), and to restrict it to a single level rather than the two levels?

On a somewhat related note, I’ve written a pretty simple plug-in that will return the first level of children (if there are any) for a specific entry, in the order specified by the “Structure” module. If anyone’s interested, I can make it available.

       
Joe Wolin's avatar
Joe Wolin
206 posts
16 years ago
Joe Wolin's avatar Joe Wolin

I’m interested so please post it. What’s the “structure” module?

       
Tyssen's avatar
Tyssen
756 posts
16 years ago
Tyssen's avatar Tyssen
I’m interested so please post it. What’s the “structure” module?

The module that this thread is about.

       
Joe Wolin's avatar
Joe Wolin
206 posts
16 years ago
Joe Wolin's avatar Joe Wolin

Ok thanks. Makes sense now.

       
First 5 6 7 8 9 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.