Highlight the active article title

I wanted to know how to style the active article title on a section landing page, so I asked the question in this thread on the ever helpful Textpattern Forums.

Els kindly posted some code, which I have adjusted slightly.

The code

<txp:if_individual_article>
	<txp:article_custom section="whatever" sort="whatever">
		<txp:if_first_article><ol class="whatever"></txp:if_first_article>
		<li<txp:if_article_id> class="active"</txp:if_article_id>><txp:permlink><txp:title /></txp:permlink></li>
		<txp:if_last_article></ol></txp:if_last_article>
	</txp:article_custom>
<txp:else />
	<txp:article_custom section="whatever" sort="whatever">
		<txp:if_first_article><ol class="whatever"></txp:if_first_article>
		<li<txp:if_first_article> class="active"</txp:if_first_article>><txp:permlink><txp:title /></txp:permlink></li>
		<txp:if_last_article></ol></txp:if_last_article>
	</txp:article_custom>
</txp:if_individual_article>

Place this in your page template, and adjust the attributes – section="whatever" etc – as required.

Another way, using a plugin

Forum moderator mrdale came up with another method, using the rvm_if_this_article plugin:

<txp:if_first_article><ul></txp:if_first_article>
<li class="<txp:rvm_if_this_article> active</txp:rvm_if_this_article>"><txp:permlink><txp:title/></txp:permlink></li>
<txp:if_last_article></ul></txp:if_last_article>

Thanks to the forum users who posted these solutions.

comments powered by Disqus