Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2011-07-10 11:40:27

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,599
Website

Re: [howto] show articles from category and augment with articles from section

Oh right, we posted at the same time. Nice solution, there too.

Ah well, I learned something in the process too.


TXP Builders – finely-crafted code, design and txp

Offline

#14 2011-07-10 12:23:21

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,012
Website GitHub Mastodon Twitter

Re: [howto] show articles from category and augment with articles from section

jakob wrote:

Nice solution, there too.

It wouldn’t have been possible without yours and Uli’s help:)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#15 2011-07-27 07:26:03

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,012
Website GitHub Mastodon Twitter

Re: [howto] show articles from category and augment with articles from section

by adding <txp:if_article_id> in the article_custom tag one can omit the current article from the generated list. Thanks to Jukka for the tip.

Latest code

<txp:variable name="relatedtexts" 
	value='<txp:related_articles limit="10" break=",">
		<txp:article_id />
	</txp:related_articles>'/>
<txp:variable name="moretexts" 
	value='<txp:article_custom 
		limit="11" section=''<txp:section />'' 
		break="," sort="rand()">
	<txp:if_article_id><txp:else /><txp:article_id /></txp:if_article_id>
	</txp:article_custom>' />

<txp:if_variable name="relatedtexts" value="">
<txp:article_custom limit="10" section='<txp:section />' break="li" wraptag="ul" sort="rand()" class="related_articles">
<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
<txp:else />

<txp:article_custom 
	wraptag="ul" 
	break="li" 
	limit="10" 
	class="related_articles" 
	id='<txp:rah_repeat offset="1" 
	break="," duplicates="1" 
	sort="regular asc" 
		value=''<txp:variable name="relatedtexts"/>,<txp:variable name="moretexts" />''>
		<txp:rah_repeat_value />
	</txp:rah_repeat>' 
		sort='field(ID,<txp:variable name="relatedtexts" />,<txp:variable name="moretexts" />)'>
   <txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
</txp:if_variable>

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#16 2011-11-20 20:10:07

TNT
Member
From: Rotterdam, Netherlands
Registered: 2006-01-06
Posts: 256
Website

Re: [howto] show articles from category and augment with articles from section

I thought this would be the solution to all my problems, but it doesn’t seem to work for me. I copied the code from the last post but it only works for articles without an assigned category. Does anyone have a clue?


Prrrrrrrr

Offline

Board footer

Powered by FluxBB