Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2006-06-20 03:06:56
- rsilletti
- Moderator

- From: Spokane WA
- Registered: 2004-04-28
- Posts: 707
Individual article style selector by category.
The following is an example of what can be done with the individual article page’s ability to recognize article based variables in the head of the html page. The conditional tags are from a plugin that allows me to use lists with my if_article_category tags and a more precise level of control with tags for both cat1 and cat2.
Any of Textpattern’s article based tags will work in this context just as well(if_article_author for instance), and the possibilities are endless!
What follows is a style selector based on the article’s category 1 assignment, and is used in the page assigned to the “article” section.
This is a recent ability, I’m not sure which revision, but it works with the current download from
Development
I have a simple example of this running at Textcastle
The Listeffects plugin for the tags used here can be downloaded here: Plugin
<code>
<txp:lfx_if_article_category1 name=”“>
<link rel=“stylesheet” href=”<txp:css />” type=“text/css” media=“screen” />
</txp:lfx_if_article_category1>
<txp:lfx_if_article_category1 name=“Basics,General,Opinions”>
<link rel=“stylesheet” href=”<txp:css />” type=“text/css” media=“screen” />
</txp:lfx_if_article_category1>
<txp:lfx_if_article_category1 name=“Code”>
<link rel=“stylesheet” href=”<txp:css n=“codestyle” />” type=“text/css” media=“screen” />
</txp:lfx_if_article_category1>
<txp:lfx_if_article_category1 name=“Plugins”>
<link rel=“stylesheet” href=”<txp:css n=“pluginstyle” />” type=“text/css” media=“screen” />
</txp:lfx_if_article_category1>
<txp:lfx_if_article_category1 name=“Tags”>
<link rel=“stylesheet” href=”<txp:css n=“tagstyle” />” type=“text/css” media=“screen” />
</txp:lfx_if_article_category1>
</code>
Offline
#2 2006-06-21 01:34:12
- NyteOwl
- Member

- From: Nova Scotia, Canada
- Registered: 2005-09-24
- Posts: 539
Re: Individual article style selector by category.
I haven’t tried it but couldn’t you just declare a CSS id or class or even the name of a file to import with the name of the appropriate category and then in the html just use one of the following:
<code>
id=”<txp:category />”
class=”<txp:category />”
@import url(<txp:category />.css)
</code>
<br />
The import would require a seperate stylesheet but (assuming it works, and I don’t know why it wouldn’t) it could be used in all recent versions.
Last edited by NyteOwl (2006-06-21 01:37:01)
Obsolescence is just a lack of imagination. / 36-bits Forever! / #include <disclaimer.h>;
Offline
#3 2006-06-21 02:58:45
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Individual article style selector by category.
Assuming you had stylesheets for each possible category, yes.
<txp:if_article_category number="1">
<link rel="stylesheet" type="text/css" media="screen" href="<txp:category1 />.css" />
</txp:if_article_category>
:)
Offline
#4 2006-06-22 02:07:29
- rsilletti
- Moderator

- From: Spokane WA
- Registered: 2004-04-28
- Posts: 707
Re: Individual article style selector by category.
Given stylesheets for each named category, this would work nice.
bc..
<txp:lfx_if_article_category1 name=“Basics,General,Opinions,Code,Plugins,Tags”>
<link rel=“stylesheet” type=“text/css” media=“screen” href=”<txp:category1 />.css” />
<txp:else />
<txp:lfx_if_article_category2 name=“Basics,General,Opinions,Code,Plugins,Tags”>
<link rel=“stylesheet” type=“text/css” media=“screen” href=”<txp:category2 />.css” />
<txp:else />
<link rel=“stylesheet” href=”<txp:css />” type=“text/css” media=“screen” />
</txp:lfx:if_article_category2>
</txp:lfx_if_article_category1>
Last edited by rsilletti (2006-06-22 03:00:52)
Offline