Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-12-21 10:52:10

brazhko
New Member
From: Stakhanov, Ukraine
Registered: 2010-12-30
Posts: 7
Website

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

#2 2012-12-21 11:24:19

wornout
Member
From: Italy
Registered: 2009-01-20
Posts: 256
Website

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

#3 2012-12-21 11:31:09

brazhko
New Member
From: Stakhanov, Ukraine
Registered: 2010-12-30
Posts: 7
Website

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

#4 2012-12-21 12:09:53

wornout
Member
From: Italy
Registered: 2009-01-20
Posts: 256
Website

Re: Sticky articles in categories

The problem is in article tag that doesn’t show sticky article…

Offline

#5 2012-12-21 12:50:58

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

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

#7 2012-12-24 20:14:26

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

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

Board footer

Powered by FluxBB