1 of 5
1
Navigator module (navigation builder)
Posted: 09 April 2006 10:43 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

Hi all,

I’ve written this module to make it easier for people to maintain navigation for their websites.
The module allows you to create navigation groups (f.i. Main Navigation, Sub-nav, Footer links) containing links to any part of your EE powered website or any custom URL.

Some of the module’s features are:
- custom ordering of items
- ordering by title and even tite length (number of characters in the item’s title)
- sorting (asc, desc)
- alternating row colors (switch parameter)
- advanced conditionals

All items (links) are dynamic, which means that if you change the name of a template_group, template, category, entry title or url_title, they will automagically keep working like they should.

Navigator is a free module, and you can download it right here, right now.

Cheers

EDIT 20081106: Updated download link to version 1.2.1

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 09 April 2006 01:07 PM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6065
Joined  08-04-2002

Cool, can’t wait to try it…Thanks!!!

Profile
 
 
Posted: 24 April 2006 11:17 AM   [ Ignore ]   [ # 2 ]  
Grad Student
Rank
Total Posts:  90
Joined  01-13-2006

This is a great Module, Thanks!
Installed it for a test.
How can navigator do something like this?:

A vertical nested List:

MAIN ONE
- sub one (= current page)
- sub two
- sub three
MAIN TWO
MAIN THREE

Then if i click on MAIN TWO it becomes:

MAIN ONE
MAIN TWO (= current page)
- sub one
- sub two
- sub three
MAIN THREE


That would be exactly what i need.

Thank you
Silvia

Profile
 
 
Posted: 24 April 2006 12:01 PM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

Thanks for the feedback.

At the moment the module does not have an easy way for building submenu’s.
I am still investigating how to implement this. There are so many ways to do menu’s…

For now there are several ways to accomplish what you described but all methods require some JavaScript knowledge.

In this example I used the {nav_properies} field to specify which items are MAIN items just by typing “main” in the Properties field.
Here is an example of the code:

<script>
function
toggleMenu(id)
{
e
= document.getElementById(id);
if (
e.style.display == "none") {
e
.style.display = "block";
} else {
e
.style.display = "none";
}
}
</script>

<div style="display:none;">
{exp:navigator group="4"}
{if nav_properties
== "main"}
</div>

<
div id="item_{nav_id}"><a href="javascript:toggleMenu('main_{nav_id}');">{nav_title}</a></div>
<
div id="main_{nav_id}" style="display:none;">

{if:else}
<div id="item_{nav_id}"> - <a href="{nav_url}">{nav_title}</a></div>
{/if}

{
/exp:navigator}
</div>

Not the most elegant solution, but it works.
If you want only one your main item open at a time (collapsing all others) you need some extra lines of JavaScript.

Cheers

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 24 April 2006 01:26 PM   [ Ignore ]   [ # 4 ]  
Grad Student
Rank
Total Posts:  90
Joined  01-13-2006

Yes, i’ve got to have only one MAIN item open and all others stay collapsed until I click on another MAIN item (otherwise the menu gets too crowded).
Do you know where I can get a good script that does it? I have seen it somewhere before but can’t remember where.
Anyway, i think your module can become a very important part of EE’s functionality pallet, so: consider this a feature request, also for some flexible current page highliting with a choice to highlite by template, by weblog, by category…
Keep up the good work!

Profile
 
 
Posted: 24 April 2006 02:05 PM   [ Ignore ]   [ # 5 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

This should do the trick:

<script type="text/JavaScript">
<!--
function
toggleMenu(id) {
var i, d, v;
for (
i=0; (d = document.getElementsByTagName("div")[i]); i++) {
if (d.className == "collapsible") {
d
.style.display = 'none';
}
}
v
= document.getElementById(id);
if (
v != null) {
v
.style.display = 'block';
}
}
//-->
</script>

<div style="display:none;">
{exp:navigator group="1"}
{if nav_properties
== "main"}
</div>

<
div id="item_{nav_id}"><a href="javascript:toggleMenu('main_{nav_id}');">{nav_title}</a></div>
<
div id="main_{nav_id}" style="display:none;" class="collapsible">

{if:else}
<div id="item_{nav_id}"> - <a href="{nav_url}">{nav_title}</a></div>
{/if}

{
/exp:navigator}
</div>

to open a specific item in a template just call the function from the body onload handler:

<body onload="toggleMenu('main_1');">

or place this script somewhere after the Navigator menu code:

<script type="text/JavaScript">
<!--
toggleMenu('main_1')
//-->
</script>

The above examples will open the first submenu when your document loads, provided the first item’s ID is “1”.

Thanks for your request, I’ll see what I can do.

[edit]Posted some unwanted code, removed it.

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 24 April 2006 02:50 PM   [ Ignore ]   [ # 6 ]  
Grad Student
Rank
Total Posts:  90
Joined  01-13-2006

What can i say: You are incredible!!
I will try this tomorrow.
Thank you so much.

Profile
 
 
Posted: 25 April 2006 05:43 AM   [ Ignore ]   [ # 7 ]  
Grad Student
Rank
Total Posts:  90
Joined  01-13-2006

I tried it and it works just fine, GREAT!
One thing though:
Neither the body onload nor the little script shows “main_1” expanded after loading that Template. All MAIN items appear in their collapsed state after loading the page so I still have to click to show the sub items. Any idea how to fix that?

Profile
 
 
Posted: 25 April 2006 05:48 AM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

I’d have to see the source code of your page, do you have a link to your site, or a file?

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 25 April 2006 09:42 AM   [ Ignore ]   [ # 9 ]  
Grad Student
Rank
Total Posts:  90
Joined  01-13-2006

OK, found it, works like a charme now.
As usual it was just a typo on my side, sorry for the intrusion.
The site is currently running offline on a MAMP server for development.
I’ll send you a link when it’s online.
Guess I owe you a view beers! That was so helpful.
Thank you,
Silvia

Profile
 
 
Posted: 25 April 2006 04:12 PM   [ Ignore ]   [ # 10 ]  
Grad Student
Rank
Total Posts:  90
Joined  01-13-2006

Me again,
I was looking for a way to include things like:
title=“homepage”, onfocus=“if(this.blur)this.blur()”, with the Navigator generated links.
I also found Navigator links are triggering IE’s Whitespace Bug when displayed in an Unordered List, so it would be useful to have an option for whitespace-less markup.
Do you plan to add such in a future »escape«?
Just asking, You know wink

Profile
 
 
Posted: 26 April 2006 01:42 AM   [ Ignore ]   [ # 11 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

Hi,

You can use the Properties field for ehm… properties, but you could also use the Description field.
Just paste your - title=“homepage” onfocus=“if(this.blur)this.blur() - etc. in there and include the variable in your code.

Here is an example that does just that, and also removes the whitespace you mentioned.

<ul id=“nav”>{exp:navigator group=“1”}
<li><a href=”{nav_url}” title=”{nav_description}” {nav_properties}>{nav_title}</a></li>{/exp:navigator}
</ul>

If this doesn’t solve your whitespace bug, have a look at one of the CSS fixes floating around the net.

Cheers

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 26 April 2006 08:09 AM   [ Ignore ]   [ # 12 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

You can also use this plugin I wrote some time ago.
It is called “Clean” and it cleans your html code by removing newline characters and/or tabs wink

Enjoy

File Attachments
pi.clean.php.zip  (File Size: 1KB - Downloads: 400)
 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 26 April 2006 02:31 PM   [ Ignore ]   [ # 13 ]  
Grad Student
Rank
Total Posts:  90
Joined  01-13-2006

Ahh, I used the Description field now, works well.
In CSS, li { display: inline;} fights my unwanted IE whitespace
Slow, but learning.

Profile
 
 
Posted: 27 April 2006 01:37 AM   [ Ignore ]   [ # 14 ]  
Research Assistant
RankRankRank
Total Posts:  547
Joined  01-05-2005

great module, thanks smile

 Signature 

Celebrating again soon.

Profile
 
 
Posted: 28 April 2006 02:38 AM   [ Ignore ]   [ # 15 ]  
Grad Student
Rank
Total Posts:  90
Joined  01-13-2006

Hi,
this menu displays just fine using nested lists, but in the markup I’m getting a repetition problem if i do this:

<div id="navcontainer">
<
ul>
<
li style="display:none;">{exp:navigator group="1"}{if nav_properties == "main"}</li>
<
li id="item_{nav_id}"><a href="javascript:toggleMenu('main_{nav_id}');"title="{nav_description}">{nav_title}</a></li>
<
li id="main_{nav_id}" style="display:none;" class="collapsible">
{if:else}
<ul>
<
li id="item_{nav_id}"><a href="{nav_url}" title="{nav_description}">{nav_title}</a></li>
</
ul>
{/if}
{
/exp:navigator}
</li>
</
ul>
</
div>

in the nested UL every LI item gets enclosed in another UL like so:

<div id="navcontainer">
<
ul>
<
li style="display:none;"></li>
<
li id="item_1"><a href="javascript:toggleMenu('main_1');">MAINLINK</a></li>
<
li id="main_1" style="display:none;" class="collapsible">
<
ul>
<
li id="item_2"><a href="http://...">Sublink_a</a></li>
</
ul>
<
ul>
<
li id="item_3"><a href="http://...">Sublink_b</a></li>
</
ul>
<
ul>
<
li id="item_4"><a href="http://...">Sublink_c</a></li>
</
ul>

placing the “if” inside the nested UL to prevent this doesn’t work.
Any idea how i can get to repeat only the Li items within one nested UL?

Just trying to get that markup correct.

Profile
 
 
Posted: 28 April 2006 08:38 AM   [ Ignore ]   [ # 16 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

I think this is what you want:

<div id="navcontainer">
<
ul>
{exp:navigator group="1"}{if nav_properties == "main"}
<li><a href="javascript:toggleMenu('main_{nav_id}');" title="{nav_description}">{nav_title}</a>
<
ul id="main_{nav_id}" style="display:none;" class="collapsible">{if:else}
<li id="item_{nav_id}"><a href="{nav_url}" title="{nav_description}">{nav_title}</a></li>{/if}
{if nav_properties
== "last_sub"}</ul>
</
li>
{/if}{/exp:navigator}
</ul>
</
div>

This works by setting the last subitem’s properties to “last_sub” and MAIN items still have “main” as their properties.

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 29 April 2006 03:19 AM   [ Ignore ]   [ # 17 ]  
Grad Student
Rank
Total Posts:  90
Joined  01-13-2006

Cocoaholic,
as i’m testing different ways to do a well structured navigation i see much potential for navigator if it manages to integrate the functionality/scripting to support different types of nav/subnav, dropdowns, accordion…
Thanks for helping.
Silvia

Profile
 
 
Posted: 29 April 2006 03:36 AM   [ Ignore ]   [ # 18 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

I don’t think I will ever offer out of the box menu’s, just the valid markup to create them.
You already have your harmonica working, you just need to add some nice AJAX fx wink

The way you can choose a Parent Category in EE seems the way to go for this module, but I would also like to keep it flexible enough so people can create other types of menu’s besides nested lists.

Ideas on how to improve the module are always welcome of course.

Don’t have much time now but I will keep you posted.

 Signature 

Member of the EE Pro Network

Profile
 
 
   
1 of 5
1
 
‹‹ Help with Pollster      Random Images ››
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64507 Total Logged-in Users: 19
Total Topics: 81066 Total Anonymous Users: 10
Total Replies: 436287 Total Guests: 155
Total Posts: 517353    
Members ( View Memberlist )
Active Members:    3000adambeazleybjyamaBruce2005CarloCG11CrucialhearsayJason Bullardjo22joemokarentemplerLisa WessRobb OttenhoffSimon Jobsupersusietcefugarchzaman