Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How Do I Create A Category of Links in the Sidebar?
So in the sidebar, it is a global object. However, in the article categories, I only want to show link categories appropriate for that article category.
That is, if the article category is “fruit”, I only want to show the link category list of fruit.
How do I do this?
Kerry Kobashi
Kobashi Computing
Offline
Re: How Do I Create A Category of Links in the Sidebar?
If I am understanding the question correctly, I think that with default TXP tags the only way to do this would be to hard-code the categories, something like:
<txp:if_category name="fruit"> <txp:linklist category="fruit" /> </txp:if_category>
which is not really practical for more than a few categories. Maybe there is a plugin that does this — it should be rather simple for a plugin.
Code is topiary
Offline
Re: How Do I Create A Category of Links in the Sidebar?
Offline
Re: How Do I Create A Category of Links in the Sidebar?
I tried the code above but it didn’t work. No output was generated. The linklist tag worked fine without the IF conditional so there is something wrong in the if test.
Let me explain again as after reading myoriginal question its confusing.
I have created in the categories tab a CSS category and in the category links tab a Web development category. What I want to happen is that when the user goes to the CSS category (/category/CSS), I want in the sidebar to display the Web Development links. The code above would seem to make sense but for some reason, the conditional is failing and no output is being generated.
<txp:if_category name="CSS">
<txp:linklist category="Web-Development" wraptag="ul" break="li"/>
</txp:if_category>
For the category in the linklist for Web Development, I’m using the category name “Web-Development” (notice dash). I tried without it and it doesnt work either.
The sidebar is a pain. Its context is global and doing anything like detecting categories, for example, seems difficult without the availability of variables to work with. And yes, I agree that this is a ugly mess because for every article category, there is a long list of if/else tags when this could suffice:
<h3>Link Categories</h3>
<txp:linklist category="<txp: category/>" />
But I don’t believe (and could get this to work) that textpattern allows for this. This almost begs for a <txp variable/> tag! If we have if and else, we should have variables too.
I dont see a means to pass variables into the parameters of a txp tag. If this was available, this would be cinch and eliminate a lot of code. Anyone know of a trick to do this? God this would be easy in PHP but this high levels scripting is a drag.
Last edited by kkobashi (2008-02-02 14:51:34)
Kerry Kobashi
Kobashi Computing
Offline
Re: How Do I Create A Category of Links in the Sidebar?
My mistake — <txp:if_category>
tests for whether or not the page is a category search. It does not test on the category of an individual article. You are right that many things would be easier with the ability to use a TXP tag as the attribute value of another TXP tag. Have you tried Zanza’s suggestion?
Code is topiary
Offline
#6 2008-02-02 16:23:54
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How Do I Create A Category of Links in the Sidebar?
kkobashi wrote:
For the category in the linklist for Web Development, I’m using the category name “Web-Development” (notice dash). I tried without it and it doesnt work either.
Don’t use uppercase in category names. So:
<txp:if_category name="css">
<txp:linklist category="web-development" wraptag="ul" break="li"/>
</txp:if_category>
To have it also work on individual article pages, use
<txp:if_individual_article>
<txp:if_article_category name="css">
<txp:linklist category="web-development" wraptag="ul" break="li"/>
</txp:if_article_category>
<txp:else />
<txp:if_category name="css">
<txp:linklist category="web-development" wraptag="ul" break="li"/>
</txp:if_category>
</txp:if_individual_article>
<h3>Link Categories</h3> <txp:linklist category="<txp: category/>" />
But I don’t believe (and could get this to work) that textpattern allows for this. This almost begs for a <txp variable/> tag! If we have if and else, we should have variables too.
Look at Zanza’s post:
<txp:asy_wondertag><txp:linklist category="<txp: category/>" /></txp:asy_wondertag>
Offline
Re: How Do I Create A Category of Links in the Sidebar?
I see there categories with capitals. Are you sure that they are category names and not titles?
God this would be easy in PHP but this high levels scripting is a drag.
<txp:php>
echo linklist(array(
'category' => category(),
));
</txp:php>
I hope that helps, you could also use asy_wondertag.
Cheers!
Last edited by Gocom (2008-02-02 18:33:08)
Offline