Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-05-17 05:50:50

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,372
Website

article custom and categories

Using article_custom, can I restrict articles which only belong to category1? I was thinking of something like

<txp:article_custom section="mysection" category1="mycategory" sort="rand()" limit="10"><txp:permlink><txp:title /></txp:permlink></txp:article_custom>

Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | Respbublika! | NeMe @ github

Offline

#2 2012-05-17 08:43:10

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,315
Website

Re: article custom and categories

I dont think you can with textpattern tag, but using smd_query sure!

Offline

#3 2012-05-17 08:53:38

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,372
Website

Re: article custom and categories

Hi Rabah,

Thanks… I’m trying to do it using native tags. I’m now experimenting with variables to achieve the above.


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | Respbublika! | NeMe @ github

Offline

#4 2012-05-17 08:59:11

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,372
Website

Re: article custom and categories

I think I have worked it out

<txp:article_custom section="mysection" category="mycategory" sort="rand()" limit="10">
<txp:variable name="categoryone" value='<txp:category1 />' />
<txp:if_variable name="categoryone" value="">
<txp:else />
<txp:permlink><txp:title /></txp:permlink>
</txp:if_variable>
</txp:article_custom>

Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | Respbublika! | NeMe @ github

Offline

#5 2012-05-17 10:35:00

geoff777
Plugin Author
From: Benarrabá Andalucía Spain
Registered: 2008-02-19
Posts: 282
Website

Re: article custom and categories

I think you could use <txp:if_article_category>

Instead of declaring the variable and the if else?


There are 10 types of people in the world: those who understand binary, and those who don’t.

Offline

#6 2012-05-17 10:55:39

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,315
Website

Re: article custom and categories

I have thinked about that solution too, but the problem is you could have less than 10 articles using limit=“10”.

Last edited by Dragondz (2012-05-17 10:56:03)

Offline

#7 2012-05-17 11:03:36

geoff777
Plugin Author
From: Benarrabá Andalucía Spain
Registered: 2008-02-19
Posts: 282
Website

Re: article custom and categories

Dragondz wrote:

I have thinked about that solution too, but the problem is you could have less than 10 articles using limit=“10”.

sure, but I’m not sure that’s a problem?


There are 10 types of people in the world: those who understand binary, and those who don’t.

Offline

#8 2012-05-17 13:15:47

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,372
Website

Re: article custom and categories

My solution is also parsing 9 articles if any article from category2 makes the random list.

I use the code in 2 places.

  1. to generate a list of “10” articles
  2. to generate one random article (I use limit-"1" for this one:))

The first case doesn’t worry me too much, the second though, does.


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | Respbublika! | NeMe @ github

Offline

#9 2012-05-22 09:10:35

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: article custom and categories

colak wrote:

Using article_custom, can I restrict articles which only belong to category1?

Welcome to aks_article plugin

<txp:aks_article section="mysection" category1="mycategory" sort="rand()" limit="10"><txp:permlink><txp:title /></txp:permlink></txp:aks_article>

Last edited by makss (2012-05-22 09:13:04)


aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

Board footer

Powered by FluxBB