Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-11-30 05:22:03

Ronamo
New Member
Registered: 2011-11-30
Posts: 2

Applying two classes to "last_section"

Here’s my situation:

I need to use the txp:section_list tag to generate an unordered list of my sections. I need the active section to have the class “active” on the “a” tag. I also need the last section in the last to have the “last” calss on the “li” tag. Here is what I’ve written up, but it doesn’t work i.e., nothing ever receives the “active” class. I’m new to Textpattern, so I suspect that this is also much, much longer than it needs to be.

Any help is greatly appreciated!

			  	<txp:section_list wraptag="ul" class="top_nav" break="" active_class="active" sections="apps,culture,design,scitech,about" include_default="0">
					<txp:if_last_section>
						<txp:if_section name="<txp:section />">
							<li class="last">
									<a class="active" href="<txp:section />"><txp:section title="1" /></a>
							</li>
							<txp:else />				
							<li class="last"><txp:section link="1" title="1" /></li>
						</txp:if_section>
						<txp:else />
							<txp:if_section name="<txp:section />">
								<li>
									<a class="active" href="<txp:section />"><txp:section title="1" /></a>
								</li>
								<txp:else />
								<li><txp:section title="1" link="1" /></li>
							</txp:if_section>
					</txp:if_last_section>
				</txp:section_list>

Offline

#2 2011-11-30 05:37:16

Ronamo
New Member
Registered: 2011-11-30
Posts: 2

Re: Applying two classes to "last_section"

Solution Found

I found a simple solution.

<txp:section_list wraptag="ul" class="top_nav" break=""  sections="apps,culture,design,scitech,about" include_default="0">
    <li class="<txp:if_last_section>last</txp:if_last_section>">
        <a href="<txp:site_url /><txp:section />" class="<txp:if_section name='<txp:section />'>active</txp:if_section_name>"><txp:section title="1" /></a>
    </li>
</txp:section_list>

Offline

#3 2011-11-30 08:17:26

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: Applying two classes to "last_section"

Good that you found the ‘nested tags solution’ by yourself. Welcome!


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

Board footer

Powered by FluxBB