Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Sticky articles in categories
Hi, guys!
This code works for me
<txp:if_category>
<txp:article status="sticky" category='<txp:category />' form="excerpt" />
</txp:if_category>
<txp:article limit="10" form="excerpt" />
It’s shows sticky articles in Category and don’t show it in Section. Perfectly! But when I open full sticky article – I see nothing. Why? Help me, what I missed?
Offline
Re: Sticky articles in categories
When you view sticky article the url should be like this:
www.example.ext/section/?c=category
But when you click on article permlink the url changes in this:
www.example.ext/section/article-title
Right?
Offline
Re: Sticky articles in categories
Exactly.
Adding pice of code
<txp:if_article_category>
<txp:article status="sticky" category='<txp:category />' form="excerpt" />
</txp:if_article_category>
solves problem.
Right?
Last edited by brazhko (2012-12-21 11:34:44)
Offline
Re: Sticky articles in categories
The problem is in article tag that doesn’t show sticky article…
Offline
Re: Sticky articles in categories
Your original code specifies that the sticky articles are only rendered on category pages. While at an article page, you are outside that category context. This means the statements inside if_category tags will not be processed, and article tag defaults to showing only articles with Live status.
As you have find out, you will need a article tag for the individual article pages too, armed with status="sticky"
. You can add something to just page context by using the if_individual_article tag. E.g.
<!--
Displays sticky article on category pages. The 'category'
attribute is unneeded, in fact it doesn't even exists.
The 'article' tag is by is by default context-sensitive, showing
content based on the requested page.
-->
<txp:if_category>
<txp:article status="sticky" form="excerpt" />
</txp:if_category>
<!--
Shows any sticky articles when accessed.
-->
<txp:if_individual_article>
<txp:article status="sticky" form="excerpt" />
</txp:if_individual_article>
<!--
Shows normal live articles and renders lists.
The 'limit' isn't needed, it defaults to '10'.
-->
<txp:article form="excerpt" />
I’ve included some pointers in the comments.
Last edited by Gocom (2012-12-21 12:51:21)
Offline
#6 2012-12-21 17:16:49
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Sticky articles in categories
It doesn’t really matter. This:
<txp:if_individual_article>
<txp:article status="sticky" />
<txp:article status="live" />
</txp:if_individual_article>
will – in inidivdual article mode – only show the requested article, no matter whether it is live or sticky.
Offline
Re: Sticky articles in categories
Els Wouldn’t
<txp:if_individual_article>
<txp:article status="sticky" />
<txp:article />
</txp:if_individual_article>
be enough :)
Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML
Offline
#8 2012-12-25 00:35:35
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Sticky articles in categories
merz1 wrote:
Els Wouldn’t (…) be enough :)
Yes, of course. I added the status="live"
just for clarity :)
Offline
Pages: 1