Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-06-21 13:55:32

6sigma
Member
From: Memphis, TN, USA
Registered: 2004-05-24
Posts: 184
Website

Basic navbar question...

I’m using a template to build a new Textpattern-based site. There will be three tabs in the horizontal (list-based) navbar.

Currently, each of the pages – Tab 1, Tab 2 and Tab 3 use the same “default” page. However, when I visit Pages 2 & 3, the navbar still has Tab 1 “highlighted” as the active page.

Must I create separate pages for Tabs 2 & 3 just to be able to style the navbar tabs appropriately?

Thanks.


“Well, I, uh, don’t think it’s quite fair to condemn a whole program because of a single slip-up, sir.” General ‘Buck’ Turgidson

Offline

#2 2006-06-21 14:09:58

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,350
Website GitHub Mastodon Twitter

Re: Basic navbar question...

there is a plugin which recognises the selected items… I forgot which one. Maybe someone here will point you to it.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2006-06-21 14:18:50

Walker
Plugin Author
From: Boston, MA
Registered: 2004-02-24
Posts: 592
Website

Re: Basic navbar question...

I dunno about template, but put a different class in the body tag and use a selector.

<code>
<body class=“homepage”>
</code>

<code>
.homepage li#hplink a, .aboutpage li#aplink a {
(styles for page you’re on)
}
</code>

Offline

#4 2006-06-21 14:43:19

6sigma
Member
From: Memphis, TN, USA
Registered: 2004-05-24
Posts: 184
Website

Re: Basic navbar question...

Thanks for the help, Walker, but I believe your solution works only if the pages for Tab 1, Tab 2 and Tab 3 are literally separate pages in Textpattern. Currently, I have one page called “default” with a separate section for each Tab.

The styling for the navbar uses syntax like [li class=“selected”] with the highlighting of the “selected” navigation button provided by CSS. However, each of the other tabs seems to require a separate page so that the particular list item for that page can carry the class “selected.” Am I wrong about this?


“Well, I, uh, don’t think it’s quite fair to condemn a whole program because of a single slip-up, sir.” General ‘Buck’ Turgidson

Offline

#5 2006-06-21 14:46:04

Walker
Plugin Author
From: Boston, MA
Registered: 2004-02-24
Posts: 592
Website

Re: Basic navbar question...

Yeah, most people use separate pages.

Offline

#6 2006-06-21 14:51:21

swf
Plugin Author
From: Saskatoon, Saskatchewan Canada
Registered: 2004-06-21
Posts: 109
Website

Re: Basic navbar question...

you shouldn’t need separate pages, but each tab should link to a different section and then you can use the <txp:if_section> tag link

Offline

#7 2006-06-21 14:54:07

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Basic navbar question...

No, you don’t need separate pages. So every tab is a section? I think it must be possible to change the code to something like this:
<code>
<li <txp:if_section name=”“>class=“selected”</txp:if_section>>Tab 1</li>
<li <txp:if_section name=“section2”>class=“selected”</txp:if_section>>Tab 2</li>
<li <txp:if_section name=“section3”>class=“selected”</txp:if_section>>Tab 3</li>
</code>

Offline

#8 2006-06-21 16:22:27

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: Basic navbar question...

…or you could just use rdt_dynamenus
which let’s you build a dynamic menu based on sections. I use it all the time.

Offline

#9 2006-06-21 16:26:50

6sigma
Member
From: Memphis, TN, USA
Registered: 2004-05-24
Posts: 184
Website

Re: Basic navbar question...

Els wrote:

No, you don’t need separate pages. So every tab is a section? I think it must be possible to change the code to something like this:
<code>
<li <txp:if_section name=”“>class=“selected”</txp:if_section>>Tab 1</li>
<li <txp:if_section name=“section2”>class=“selected”</txp:if_section>>Tab 2</li>
<li <txp:if_section name=“section3”>class=“selected”</txp:if_section>>Tab 3</li>
</code>

Tough day here! This junk takes FOREVER to troubleshoot and fix.

Here’s the site I’ve been working on. For some reason the “home” button doesn’t highlight when Home is the displayed page, but Els’s suggestions solved the navbar issue on the other two pages. Thanks.


“Well, I, uh, don’t think it’s quite fair to condemn a whole program because of a single slip-up, sir.” General ‘Buck’ Turgidson

Offline

#10 2006-06-21 17:43:59

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Basic navbar question...

I just realized: you’d better move the space after ‘li’ to inside the conditional tag, like this:
<li<txp:if_section name=""> class="selected"</txp:if_section>>Tab 1</li>, otherwise if there is no class you end up with a space that shouldn’t be there (<li >). Though it seems to validate just fine.

But I don’t understand why when on the home page no class is added to the <li>. Are you sure there is no typo?

Offline

#11 2006-06-21 18:25:12

6sigma
Member
From: Memphis, TN, USA
Registered: 2004-05-24
Posts: 184
Website

Re: Basic navbar question...

Els wrote:

Are you sure there is no typo?

Again, I appreciate your help. Here’s the code for the navbar:
<code>
<li<txp:if_section name=“Default”> class=“selected”</txp:if_section>><a href=“http://itworx.net”>Home</a></li>
<li<txp:if_section name=“about”> class=“selected”</txp:if_section>><a href=“http://itworx.net/about/”>About</a></li>
<li<txp:if_section name=“services”> class=“selected”</txp:if_section>><a href=“http://itworx.net/services/”>Services</a></li>
</code>


“Well, I, uh, don’t think it’s quite fair to condemn a whole program because of a single slip-up, sir.” General ‘Buck’ Turgidson

Offline

#12 2006-06-21 18:33:57

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Basic navbar question...

Don’t use name="default". It should be name="".

Last edited by els (2006-06-21 18:34:19)

Offline

Board footer

Powered by FluxBB