Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Using if_article_category
I’m implementing the “Archive page in article” tip http://txptips.com/archive-page-in-an-article and ran into a snag. Not with it, but integrating in the site.
I have a single article form br_article that handles both article lists and individual articles. For the archive page, I don’t need the posted date, author, and other things related to an individual article. The form has:
<txp:if_individual_article>
<txp:if_article_category name="Blog Archive">
<txp:body />
<txp:else />
... individual article tags ...
</txp:if_article_category>
</txp:if_individual_article>
The article has Category 1 assigned to “Blog Archive”. In categories, its parent is Blog.
Blog (0)
Blog Archive (1)
Whatever (7)
When the page is rendered, it goes through the if_individual_article
but not the if_article_category
. The post time, author information, and comment information is shown.
I turned on the tag trace and have:
<txp:if_individual_article>
[<txp:if_individual_article>: true]
<txp:if_article_category name="Blog Archive">
[<txp:if_article_category name="Blog Archive">: false]
<txp:permlink>
<txp:title />
</txp:permlink>
<txp:posted />
...
I double checked the article, and category 1 is “Blog Archive”. I also tried <txp:if_article_category name="Blog Archive" number="1">
to force Category 1, but it still evaluates to false.
Is there something special I need to do because the Blog Archive is a child and not a level 1 entry?
Thanks,
Loyd
Offline
Re: Using if_article_category
I think I found the solution. For multiword tags, use a dash (-) instead of space: <txp:if_article_category name="blog-archive">
. Documented? :)
Offline
Re: Using if_article_category
It looks like you were using the category title rather the name.
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. – if article category
Offline
Re: Using if_article_category
The examples for if_article_category are vague. From the tag reference,
<txp:if_article_category name="Prose" number="1">
<p><txp:category1 /></p>
</txp:if_article_category>
Since “Prose” is properly capitalized, it implies I should be able to use the Title as presented on the Categories / Article Categories screen. if_article_category
does not have a title attribute like some of the other tags. Multiword names are not mentioned. I found this by looking in the textpattern
table.
No worries, I have it working and now chasing other issues.
Thanks!
Offline
#5 2011-01-28 16:45:51
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Using if_article_category
Category (or section) names should not contain capitals; when you create a category ‘My Category’, that will be its title, and the name is converted to ‘my-category’. As values for tag attributes, always use the (category or section) names.
Offline
Re: Using if_article_category
logo1664 wrote:
Since “Prose” is properly capitalized, it implies I should be able to use the Title
Good catch. Documentation updated.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#7 2011-01-28 17:49:53
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Using if_article_category
Bloke wrote:
Good catch. Documentation updated.
Doh! I really thought we caught them all… we need an smd_where_used for the wiki ;)
Offline
Re: Using if_article_category
Awesome!
Offline
#9 2011-01-28 18:06:32
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,315
Re: Using if_article_category
Caught some more in section tags. Hope these were the last ones.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Pages: 1