Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#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
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&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&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
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&c=angelo-brand">Angelo Brand</a></li> <li><a href="http://exmple.dev/index.php?s=products&c=cheeses">Cheeses</a></li> <li><a href="http://example.dev/index.php?s=products&c=pagani">Pagani</a></li> <li><a href="http://example.dev/index.php?s=products&c=parmesan">Parmesan</a></li> <li><a href="http://example.dev/index.php?s=products&c=riso">Riso</a></li> <li><a href="http://example.dev/index.php?s=products&c=sagra-olive-oil">Sagra Olive Oil</a></li> <li class="active"><a href="http://example.dev/index.php?s=products&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
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 assumeclass=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
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 assumeclass=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