Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-04-17 12:08:49

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Related articles limited by section

I’m struggling to find a way to fetch articles related by section without specifying a category, which the native related_articles tag requires:

If both categories are left blank, then no articles are selected

chh_related_articles almost works, but it requires something in the relation attribute (not section, which has its own attr). And man, it’s old.

Are other options apart from smd_query?

Offline

#2 2012-04-17 12:26:14

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: Related articles limited by section

Couldn’t you work around it with an article_custom and if_article_id to exclude the current one?


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#3 2012-04-17 13:59:59

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: Related articles limited by section

Hi Uli

I did this previously:

<txp:if_article_id><txp:else />
{output tags}
</txp:if_article_id>

But if I only need to fetch one article and it happens to be the current one then I get nothing back.

I guess I could put a second txp:article_custom tag with an offset into the first if part of that statement…

Will try that now.

Offline

#4 2012-04-17 14:13:53

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: Related articles limited by section

Well, it feels like it should be possible with less code, but that works. Thanks for pointing me in the right direction Uli.

Offline

#5 2012-04-17 14:38:06

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: Related articles limited by section

You’re welcome.

pieman wrote:

second txp:article_custom tag with an offset [snip] Well, it feels like it should be possible with less code

Sometimes it’d be nice to simply put conditionals around attribute/value pairs, yup ;)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

Board footer

Powered by FluxBB