if article category
From Textbook
<txp:if_article_category>
The if_article_category tag is a conditional tag and always used as an opening and closing pair, like this...
<txp:if_article_category> ...conditional statement... </txp:if_article_category>
It will execute the contained statement if the category name associated with a particular article (Category1 or Category2) matches the values of the name and number attributes. Should be used in an article form.
Contents |
Attributes
Tag will accept the following attributes (case-sensitive):
- name="category"
- Comma-separated list of category names to match.
- Default: unset.
- number="number"
- match category in Cat1 or Cat2 (or both).
- Values:
1or2 - Default: unset, causing both categories to be matched against the specified name.
Examples
Example 1: Display matched category
<txp:if_article_category name="Prose" number="1"> <p><txp:category1 /></p> </txp:if_article_category>
- What this does...
- If the Category1 assigned to the article is "Prose", the category is displayed.
Other tags used: category1
Example 2: Using the tag with else
<txp:if_article_category name="Prose" number="1"> <p>Fun With Prose</p> <txp:else /> <p><a href="index.php">Home</a></p> </txp:if_article_category>
- What this does...
- Displays the welcome text if the category and category number match the given values, or shows a default link otherwise.
Other tags used: else
Example 3: Display a list of matching links
In an article form, put the following set of conditionals for each category you want to look for:
<txp:if_article_category name="yourcategory" number="1"> <ul> <txp:article_custom form="sub" category="yourcategory" sortby="Posted" sortdir="asc" /> </ul> </txp:if_article_category>
And then your article form (in this case called 'sub') can be used to list links to other articles like this:
<li><txp:permlink><txp:title /></txp:permlink></li>
- What it does...
- Lists articles of the same category as the current article's Category1
Other tags used: article_custom, else, title, permlink




