Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-12-06 12:48:21

FireFusion
Member
Registered: 2005-05-10
Posts: 698

Active class on container tag section list?

The active_class attribute doesn’t work on a section list if in container tag more. Is there a way around this?

<!-- main navigation -->
<div id="nav_main">
<txp:section_list 

sections="buddhist-center,weekly-classes,special-events,kadampa-buddhism,public-service,information"

default_title='<txp:text item="home" />' include_default="1" wraptag="ul" break="li" class="tabs" active_class="current">
<txp:section link="1" title="1" />
	<txp:article_custom  section='<txp:section />' wraptag="ul" sort="position asc">
		<li><a href="<txp:permlink />" <txp:if_article_id>class="current"</txp:if_article_id>><txp:title /></a></li>
	</txp:article_custom>
</txp:section_list>

</div>

Last edited by FireFusion (2008-12-06 12:48:30)

Offline

#2 2008-12-06 12:53:37

FireFusion
Member
Registered: 2005-05-10
Posts: 698

Re: Active class on container tag section list?

Thought I found a way but this doesn’t work either…

- <txp:section link="1" title="1" />
+ <a href="<txp:section url="1" />" <txp:if_section name="<txp:section />">class="current"</txp:if_section>><txp:section title="1" /></a>

Offline

#3 2008-12-06 14:00:14

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

Re: Active class on container tag section list?

I don’t know why the active class doesn’t work in section_list as container tag, but this works:

<txp:variable name="sec" value='<txp:section />' />

<txp:section_list sections="sec1,sec2,sec3,sec4" default_title='<txp:text item="home" />' include_default="1" wraptag="ul" break="li" class="tabs">
	<txp:section link="1" title="1" class='<txp:if_variable name="sec" value=''<txp:section />''>current</txp:if_variable>' />
	<txp:article_custom section='<txp:section />' wraptag="ul">
		<li><a href="<txp:permlink />"<txp:if_article_id> class="current"</txp:if_article_id>><txp:title /></a></li>
	</txp:article_custom>
</txp:section_list>

No idea why, but it doesn’t even output class="" if it’s not the current section… :)

BTW nice way to build a menu!

Last edited by els (2008-12-06 14:04:22)

Offline

#4 2008-12-06 14:21:16

FireFusion
Member
Registered: 2005-05-10
Posts: 698

Re: Active class on container tag section list?

Excellent thanks els

Offline

#5 2008-12-06 16:51:51

keith
Member
From: Blyth, Northumberland, England
Registered: 2004-12-08
Posts: 199
Website

Re: Active class on container tag section list?

Uuummm… is the double right chevron in the first two examples causing the problem?


Keith
Blyth, Northumberland, England
Capture The Moment

Offline

#6 2008-12-06 17:04:32

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Active class on container tag section list?

Single quotes with your tag as an attribute might make a difference, the parser is probably just treating the tag as text.

<txp:if_section name="<txp:section />">class="current"...

Last edited by rsilletti (2008-12-06 17:11:39)

Offline

#7 2008-12-06 17:15:48

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

Re: Active class on container tag section list?

rsilletti wrote:

Single quotes with your tag as an attribute might make a difference, the parser is probably just treating the tag as text.

It wouldn’t have worked with single quotes either, because <txp:section /> is now context sensitive, and inside a section list it returns the ‘current’ section in the list, and not the section currently being viewed.

Offline

#8 2008-12-06 17:34:38

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Active class on container tag section list?

Ok, I’m a little confused – why does it work as expected as an attribute for article custom?

Offline

#9 2008-12-06 17:38:55

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

Re: Active class on container tag section list?

Because article_custom is not a section list? Edit: that was not correct. As an attribute in the article_custom tag (in this case) it still is part of the section list, so it returns the section as indicated by the list.

Here is a post by wet that helped me understand it (a bit).

Last edited by els (2008-12-06 17:41:57)

Offline

#10 2008-12-06 17:47:30

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Active class on container tag section list?

Just to be more precise: txp:section was always (pre 4.0.7) context sensitive. Sensitive contexts for that tags were: the currently viewed section, and the currently being rendered article.

Now (4.0.7), there is also a list context (as in txp:section_list).

Mmm, in fact, in the code posted on the first post, it is used as an attribute for article_custom but it’s also in a list (section_list) context, so it would be sensible to the current iteration for section_list.

Edit: Els was faster.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#11 2008-12-06 18:17:28

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Active class on container tag section list?

Part of the reason I am pursuing this has to do with a plugin I created. Originally it was intended to be a way of getting a clear idea of exactly how these container lists work. Much of the code was patterned after section_list and all seems to work as expected. My problem here is the idea of releasing a plugin whose operation I’m unsure I understand entirely. Every time I think I have it I run into something slippery that doesn’t make sense to me.

Offline

Board footer

Powered by FluxBB