templates / navigation help?
Posted: 17 May 2006 06:31 AM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  138
Joined  04-13-2006

I am building a site with many sections - at present the navigation elements have been created as a template with the links hard coded into them

eg
  <li>News</li>
  <li>Features</li>
  <li>Events</li>
  <li>something</li>
  <li>something else</li>
  <li>Magazine</li>
  <li>Media</li>
  <li>Competitions</li>

(should this nav be created dynamically?? If it were created dynamically is there a way of retaining the user-friendly urls?)

I have then created templates for each section that the nav links to

ie

.com/site/events/ will link to the event template.

It seems counter-intuitive to create the pages this way - am I going about it entirely the wrong way? I am assuming the categories are then for subnavs within the section?

Profile
 
 
Posted: 17 May 2006 07:28 AM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9254
Joined  04-15-2006

Hi there actionsm,

That is actually exactly the way that I have created a navigation on a site that I am putting together at the moment.
This is in itself a very solid way of programming a navigation. If you place this into say an includes template group and call it something like navigation_bar or whatever you like then you can just use the following code to embed the navigation into your site templates :

{embed="includes/navitation_bar"}

The great thing about this method is that should you need to change one of the links then you only have to do it once and then any page templates where you have this code embedded as shown in the code above would automatically reflect this change.

As to creating this kind of thing dynamically I am not too sure how you would go about doing that. I don’t think there is a set way of EE knowing what your sections are called as you may on one site have a news, features and contacts page but on another site you may have a news, images, forums and contact page so that would change depending upon your site circumstances.

The only way I think that you could do this (please someone correct me if I’m wrong though) would be by utilizing a custom EE query.

Hope some of that helped somewhere along the way.

Best wishes,

Mark Bowen

 Signature 

Shopping Cart Plugin
Full list of add-ons
———————————————————-
Buy me a drink, or two if you like!!

Profile
 
 
Posted: 17 May 2006 07:51 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
RankRank
Total Posts:  138
Joined  04-13-2006

Thanks for the help, thought it was right, but just needed some reassurance grin

Cheers

Profile
 
 
Posted: 17 May 2006 07:53 AM   [ Ignore ]   [ # 3 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  24513
Joined  05-20-2002

Lots of different ways to go at this- and as Mark points out above, I’d definitely be putting this nav into either another template or a global and then including it everywhere you need it.  That way- only one thing to change and the nav is changed site wide.

As to dynamically generating it- these are sections/weblogs?  If so, you could write a simple query that would pull out all of your weblogs.  However, as much as I love queries, I wouldn’t recommend it in this case.  This is fairly static info, no point in wasting a query on it.  And if you embed it, you’ve only got one spot to change for those site wide changes.  So really- I’d stick with static in this case.

The last issue is the trickiest- whether to create a separate template for each of your sections/weblogs.  Lot of ways you could go at it.  What I’d probably do- and it really depends a lot on how many sections you’ll have- I’d probably have a separate template for each ‘main/multi-entry page’, then share all of the single entry bits- such as comment pages.  BUT- you’ve about got enough different sections to make that a pain- in which case I would use one template for ALL multi-entry sections, one for all single entry sections- and pass the weblog shortname in the url, grabbing it out dynamically and setting it in the weblog tag parameter using the segment.  Trickier to set up- but if you other option is creating 10-15 templates and keeping up with them- worth it.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 17 May 2006 07:54 AM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  891
Joined  02-05-2002

Check out the Navigator Module, it might do what you want.

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 18 May 2006 09:38 AM   [ Ignore ]   [ # 5 ]  
Lab Assistant
RankRank
Total Posts:  138
Joined  04-13-2006
rob1 - 17 May 2006 07:53 AM

BUT- you’ve about got enough different sections to make that a pain- in which case I would use one template for ALL multi-entry sections, one for all single entry sections- and pass the weblog shortname in the url, grabbing it out dynamically and setting it in the weblog tag parameter using the segment.  Trickier to set up- but if you other option is creating 10-15 templates and keeping up with them- worth it.

Thanks for this reply - how would I specify the template if I were not linking to it directly? Would I need to use a different template group and have it default to the index template or can I specify the template with the segment?

Profile
 
 
Posted: 18 May 2006 11:26 AM   [ Ignore ]   [ # 6 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  24513
Joined  05-20-2002

There are different ways to go at it- the easies is to pass the weblog shortname in a segment- you’d need that for multi-entry pages where you want a different page for each weblog.  Then you’d grab the segment via {exp:weblog:entries weblog=”{segment_3}”} - for a simple example.

Let me poke around on the wiki- not sure I’ve seen a tutorial on how to do it, though I know folks are doing it.  There’s a least one post I recall that involves a little hack that gives you the weblog shortname as a variable- which helps build in-weblog category links that send the weblog shortname in the url.  Which you may/may not need to do.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
   
 
 
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: 77557 Total Logged-in Users: 47
Total Topics: 101552 Total Anonymous Users: 25
Total Replies: 544386 Total Guests: 282
Total Posts: 645938    
Members ( View Memberlist )