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

Navigator module (navigation builder)

Development and Programming

Cocoaholic's avatar
Cocoaholic
445 posts
about 19 years ago
Cocoaholic's avatar Cocoaholic

Sue,

Thanks for the feedback.

Cloning groups would be nice, might look into that.

Wouldn’t it be wiser (and easier to maintain) to use another way to change the class? Conditionals perhaps?

Can you explain your setup / what you are trying to do / show us some code?

Cheers

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
about 19 years ago
Sue Crocker's avatar Sue Crocker

It probably would be easier to use something like Jesse’s technique to set a class: Dynamic CSS Navigation and use the Navigation Builder to just use the class=”whatever-segment-three-is” instead.

Then set the style based on {segment_3}

       
dreamscape's avatar
dreamscape
7 posts
about 19 years ago
dreamscape's avatar dreamscape

First off, great module. It has been a tremendous help in managing all the menus for the site I’m building. I’m even using it to build the sitemap (I have a “sitemap” navigator group that holds the group names of the menus to compile the sitemap with).

But I find having to use the ID to pull the navigator menu you want to be confusing at best when you’ve got more than a few menus (16 and counting here), and it also makes it difficult to tie the url to the menus. So I made a simple change to the module that allows you to use the group short name instead if you want to.

I thought I’d post it here incase anyone else might be interested in achieving the same. It’s really quite simple. Just open mod.navigator.php and find on lines 73-79:

// -------------------------------------------------------
        //    Fetch all data from Navigator Group
        // -------------------------------------------------------
        
        $query = $DB->query("SELECT * FROM exp_navigator_data
                             WHERE group_id = $group_id
                             ORDER BY $orderby $sort");

And replace with:

// -------------------------------------------------------
        //    Fetch all data from Navigator Group
        // -------------------------------------------------------

        if (is_numeric($group_id)) {
            $group_id = (int)$group_id;
            $query = $DB->query("SELECT * FROM exp_navigator_data
                                 WHERE group_id = $group_id
                                 ORDER BY $orderby $sort");
        } else {
            $group_title = $DB->escape_str($group_id);
            $query = $DB->query("SELECT nd.* FROM 
                                    exp_navigator_data nd, 
                                    exp_navigator_groups ng 
                                 WHERE ng.group_title = '$group_title' AND 
                                    ng.group_id = nd.group_id 
                                 ORDER BY $orderby $sort");
        }[/code]

That's it.  It will still accept the ID if you pass a numeric value, or will use the group short name/title if not, i.e:
[code]
<!-- Both are accepted now -->

{exp:navigator group="12"}
    <!-- ... -->
{/exp:navigator}


{exp:navigator group="group_name"}
    <!-- ... -->
{/exp:navigator}

It’s been a life saver for me 😉

I also added a “count” coditional param because there are sometimes I want to do something every so many itterations. This was also very easy to add. For anyone interested, again in the mod.navigator.php file, go down to roughly link 225 and find:

// -------------------------------------------------------
            //    Prep Conditionals
            // -------------------------------------------------------
            
            //$cond['sub_items'] = ($subitems[$i] != 'parent') ? 'FALSE' : 'TRUE';
            //$cond['last_sub_item'] = ($subitems[$i] != 'last_sub_item') ? 'FALSE' : 'TRUE';
            
            $cond['nav_title'] = ($row['nav_title'] == '0') ? 'FALSE' : $row['nav_title'];

And replace with:

// -------------------------------------------------------
            //    Prep Conditionals
            // -------------------------------------------------------

            //$cond['sub_items'] = ($subitems[$i] != 'parent') ? 'FALSE' : 'TRUE';
            //$cond['last_sub_item'] = ($subitems[$i] != 'last_sub_item') ? 'FALSE' : 'TRUE';

            $cond['count'] = $i;

            $cond['nav_title'] = ($row['nav_title'] == '0') ? 'FALSE' : $row['nav_title'];[/code]

That's all again.  Now you can use a count conditional, i.e:
[code]
{exp:navigator group="group_name"}
    {if (count == "6") || (count == "11") || (count == "16") || (count == "21")}
        <!-- ... -->
    {if:else}
        <!-- ... -->
    {/if}
{/exp:navigator}

Anyways, just wanted to share that, and thanks again for the great module 😊

       
Cocoaholic's avatar
Cocoaholic
445 posts
about 19 years ago
Cocoaholic's avatar Cocoaholic

Hi dreamscape,

Thanks for sharing your additions to the module! If you don’t mind I’ll add these to the next version 😊

btw, I’d love to see how you built that sitemap.

Cheers

       
dreamscape's avatar
dreamscape
7 posts
about 19 years ago
dreamscape's avatar dreamscape
btw, I’d love to see how you built that sitemap.

Sure, here is how I’m doing it. - I have a navigator group that I call “Site Map” that just holds references to the navigator groups I want in my sitemap. (This is for a human site map, but the same principles could be used to build an XML sitemap for Google) - The reference for each group in the sitemap is kept in the Properties field. The entries only have this filled in with the navigator group they represent + the title. - Then, I just nest navigator tags in the template to build the sitemap. I found you cannot directly nest them; however, you can use embed to nest them.

Here is some basic template code for 2 templates, site/sitemap (the main sitemap), and site/sitemap-sub (each group in the sitemap):

site/sitemap:

<h1>Site Map</h1>
<ul>
{exp:navigator group="sitemap"}
    <li><h2>{nav_title}</h2>
        {embed="site/sitemap-sub" group="{nav_properties}"}
    </li>
{/exp:navigator}
</ul>

site/sitemap-sub:

<ul>
{exp:navigator group="{embed:group}"}
    <li><h3><a href="http://{nav_url}">{nav_title}</a></h3></li>
{/exp:navigator}
</ul>

It is working quite well for me, and saves me from having to manually make the sitemap or duplicate existing navigator groups 😉

In addition to a sitemap, it would also work well if you wanted to show numerous navigator groups together on certain pages/sections and there was some crossover. Instead of making groups that crossover or manually coding the right groups for each section into the template, one could make a single group for each section that just controls which navigator groups are to appear and in what order. I haven’t used this little trick to do this yet, but I have a feeling I will for a couple sections of the site I am building.

       
Cocoaholic's avatar
Cocoaholic
445 posts
about 19 years ago
Cocoaholic's avatar Cocoaholic

Smart solution.

I knew nesting navigator groups doesn’t work so I was curious how you did it. Good to know “embed” will do the trick.

I thought you might have used some AJAX workaround, which is what I do to get dynamic data into EE’s static templates like the “User Message Template”.

Thanks.

       
ignite's avatar
ignite
149 posts
18 years ago
ignite's avatar ignite

dreamscape, any chance we could see those two solutions in action by posting a link to the site when it’s ready? 😊

       
Ryan M.'s avatar
Ryan M.
1,511 posts
18 years ago
Ryan M.'s avatar Ryan M.

I installed this plugin and definitely wanted to refer to my groups using names rather than IDs as well, so I made the modification to the query that dreamscape suggested - but it didn’t work because I don’t have a group_title field in my exp_navigator_groups table. There are only two columns - group_id and group_name. Don’t know why I’m missing that field, but I just changed the query to refer to the group_name instead:

} else {
  $group_title = $DB->escape_str($group_id);
  $query = $DB->query("SELECT nd.* FROM
  exp_navigator_data nd,
  exp_navigator_groups ng
  WHERE ng.group_name = '$group_title' AND ng.group_id = nd.group_id
  ORDER BY $orderby $sort");
}

I Just changed the WHERE clause to reference group_name and can now refer to navigation groups like this:

{exp:navigator group="Footer Nav"}

Being a web designer, those capitals and the space bug me - I’d much rather it read

{exp:navigator group="footer-nav"}

but it appears to work for me right now. Any idea why I don’t have that group_title column in my table? Do I have an older version of this module (using Navigator Build: 20060413 aka v1.0)? Did I miss something in this thread? Time to reread…

       
dreamscape's avatar
dreamscape
7 posts
18 years ago
dreamscape's avatar dreamscape
Did I miss something in this thread?

Oops, I missed something. It appears I modified my navigator module to put in a group short name (ie the group_title) field. I’ve made a number of mods to it, and just forgot that one was a mod and not in there by default.

       
Cocoaholic's avatar
Cocoaholic
445 posts
18 years ago
Cocoaholic's avatar Cocoaholic

Hi all,

I will implement the changes made by dreamscape after the weekend.

Cheers

       
Ryan M.'s avatar
Ryan M.
1,511 posts
18 years ago
Ryan M.'s avatar Ryan M.

Hey Cocoaholic, want to make your version of a PageTree module while you’re at it? I’m currently doing my site’s sitemap with the Navigator module and dreamscape’s method (which is pretty cool!) but it looked like the PageTree module would allow for nesting a little easier.

Is there any way to make relationships between Navigator groups? Like Navigator ID 31 is a child of ID 5? I guess that would be similar to how categories are set up in the category groups. I don’t really get how I could use categories in the case of the (human) sitemap, because I’m not really using categories on my site (most of the pages are just single-entry pages) and the links wouldn’t match the ‘arbitrary’ links I’ve given to each item in my Navigator groups.

Anyway, it’s early. Haven’t had enough coffee. Let me say again how helpful I think the Navigator module has been, thanks!

       
Cocoaholic's avatar
Cocoaholic
445 posts
18 years ago
Cocoaholic's avatar Cocoaholic

I updated the module to version 1.1

The only changes are the additions made by dreamscape.

  • You can now use Group Names as well as the group ID.
  • Added the ‘count’ conditional.

download link

       
Ryan M.'s avatar
Ryan M.
1,511 posts
18 years ago
Ryan M.'s avatar Ryan M.

I think it’s been suggested before, but for the particular project I’m working on right now, a “Duplicate Group” feature would be VERY handy. Maybe for version 1.2? Thanks for a very useful module.

       
ayza's avatar
ayza
71 posts
18 years ago
ayza's avatar ayza

Hi,

I’ve have a simple question: Does the Navigator module provide some kind of class or ID for the menu item of the page/template currently showing, are so I can hook that into the CSS with a different styling? Or can I make some kind of conditional or property so I get an active or selected to hook into the CSS? If so, please show an example for the code.

Thanks for a very useful module.

/ Ayza

       
nullbreached's avatar
nullbreached
116 posts
18 years ago
nullbreached's avatar nullbreached

I’ve read though everything in this entry and I think this is exactly what I am looking for. I just am a newbie and trying to learn the ins and outs of this drop down navigator.

Here’s my code for one button:



I installed the navigator module and started to read the documentation. Some makes sense, while other stuff goes over my head just a little. How would I make this dynamic? You can see the CSS/XHTML version of the website (without EE) at http://studio805.com/ca/ I am working locally before I upload.

The rest of the code (or navigation has the same structure) but of course each menu item wouldn’t have the same submenus. Any advice is most appreciated.

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