Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2011-01-23 22:27:06

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

Re: category_list not setting active_class

Looks like more plugins that handle categories influence if_category, here is a post about rss_unlimited_categories.

Anyway, instead of variable/if_variable you can also use esq_ifcategory.

Offline

#26 2011-01-24 00:53:20

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,092
Website Mastodon

Re: category_list not setting active_class

Ok i thought i had it working but apparently not. The present output gets formatted this way:

<li class="active"><a href="http://example.dev/index.php?s=products&amp;c=tiger-brand">Tiger Brand</a></li>

But I need the code to format the links so it looks like this:

<li><a class="active" href="http://example.dev/index.php?s=products&amp;c=tiger-brand">Tiger Brand</a></li>

<li> etc… </li>

( i note that this is the output format for active class that the cbs_navigation_menu outputs the section links )

I tried various changes to this line in the code without success.

<li<txp:if_variable name="cat" value='<txp:category />'> class="active"</txp:if_variable>><txp:category title="1" link="1" /></li>

i need the class active inside a closing <li>

Last edited by bici (2011-01-24 00:55:38)


…. texted postive

Offline

#27 2011-01-24 05:53:55

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,092
Website Mastodon

Re: category_list not setting active_class

ps here is my html output:

 
<div id="leftnava"><div id="nav">
    <ul class="category_list">
	  	<li><a href="http://example.dev/index.php?s=products&amp;c=angelo-brand">Angelo Brand</a></li>
   	  	<li><a href="http://exmple.dev/index.php?s=products&amp;c=cheeses">Cheeses</a></li>
   	  	<li><a href="http://example.dev/index.php?s=products&amp;c=pagani">Pagani</a></li>
   	  	<li><a href="http://example.dev/index.php?s=products&amp;c=parmesan">Parmesan</a></li>
   	  	<li><a href="http://example.dev/index.php?s=products&amp;c=riso">Riso</a></li>
   	  	<li><a href="http://example.dev/index.php?s=products&amp;c=sagra-olive-oil">Sagra Olive Oil</a></li>
   	  	<li class="active"><a href="http://example.dev/index.php?s=products&amp;c=tiger-brand">Tiger Brand</a></li>
   </ul> 

my url:
html > body #product > div .container > div #main .span-24 last > div #sidebar .span-6 > div #leftnava > div #nav > ul .category_list > li .active > a

Last edited by bici (2011-01-24 05:54:57)


…. texted postive

Offline

#28 2011-01-24 08:02:08

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

Re: category_list not setting active_class

<li><txp:category class='<txp:if_variable name="cat" value=''<txp:category />''>active</txp:if_variable>' title="1" link="1" /></li>

Note that this outputs a class="" for not active links, you can add a <txp:else /> if you want to add another class name instead of empty.

And of course you need to change the css back to li a.active.

Edit: corrected a mistake in my code.

Last edited by els (2011-01-24 20:32:43)

Offline

#29 2011-01-24 19:01:35

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,092
Website Mastodon

Re: category_list not setting active_class

Els wrote:

bc. <li><txp:category class=’<txp:if_variable name=“cat” value=’‘<txp:category />’‘> class=“active”</txp:if_variable>’ title=“1” link=“1” /></li>

Note that this outputs a class="" for not active links, you can add a <txp:else /> if you want to add another class name instead of empty.

And of course you need to change the css back to li a.active.

wow! thanks! I will try that this evening when i get back to my mamp installation. not sure how to use <txp:else /> ? Altho i assume class=empty is fine


…. texted postive

Offline

#30 2011-01-24 20:32:00

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

Re: category_list not setting active_class

Sorry, I noticed I made a mistake in my last code example, corrected it now.

not sure how to use <txp:else /> ? Altho i assume class=empty is fine

Something like this:

<li><txp:category class='<txp:if_variable name="cat" value=''<txp:category />''>active<txp:else />inactive</txp:if_variable>' title="1" link="1" /></li>

BTW, on second thought I think you can just as well replace <txp:page_url type="c" /> with <txp:category /> in the <txp:variable /> tag in this code.

Last edited by els (2011-01-24 20:34:29)

Offline

#31 2011-01-26 04:03:54

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,092
Website Mastodon

Re: category_list not setting active_class

Els wrote:

Sorry, I noticed I made a mistake in my last code example, corrected it now.

not sure how to use <txp:else /> ? Altho i assume class=empty is fine

Something like this:

<li><txp:category class='<txp:if_variable name="cat" value=''<txp:category />''>active<txp:else />inactive</txp:if_variable>' title="1" link="1" /></li>

BTW, on second thought I think you can just as well replace <txp:page_url type="c" /> with <txp:category /> in the <txp:variable /> tag in this code.

lovely! many thanks…


…. texted postive

Offline

Board footer

Powered by FluxBB