Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2009-07-23 15:42:01
- alannie
- Member
- From: Minnesota, USA
- Registered: 2005-09-15
- Posts: 150
Filter by parent category?
I have a group of articles that I want to randomly display on my home page using article_custom
. Those articles are all in various categories, which are under a single parent category. Since article_custom has no parent category attribute, I tried specifying category_list
as the category attribute, but this doesn’t work. TXP doesn’t seem to recognize the nested category_list
closing tag and encodes the rest of the tag as HTML entities.
<txp:article_custom category="<txp:category_list parent='parent1' break=','><txp:category link='0' /></txp:category_list>" sort="rand()" limit="1" />
Ideas?
Offline
Re: Filter by parent category?
alannie
Does this work? (untested)
<txp:article_custom category='<txp:category_list parent="parent1" break=","><txp:category link="0" /></txp:category_list>' sort="rand()" limit="1" />
(note the single quotes surrounding the category attribute and that the tags-in-tags use conventional double quotes)
Last edited by Bloke (2009-07-23 15:51:31)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Online
#3 2009-07-23 16:06:34
- alannie
- Member
- From: Minnesota, USA
- Registered: 2005-09-15
- Posts: 150
Re: Filter by parent category?
Hi Stef, I tried the quote swap as you suggested and it still converts everything after the category list into HTML entities.
I also tried something different – I moved the code out of the article into a form. Result: the rest of the page renders, but the place where the code should have output something is blank (checked source code and nothing there either).
Offline
#4 2009-07-29 22:46:02
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Filter by parent category?
alannie wrote:
I tried the quote swap as you suggested and it still converts everything after the category list into HTML entities.
Don’t know if you already solved this, but tags as attributes can only be used in 4.0.7 or higher. Otherwise you need a plugin (and use double quotes).
Offline
#5 2009-08-03 15:15:01
- alannie
- Member
- From: Minnesota, USA
- Registered: 2005-09-15
- Posts: 150
Re: Filter by parent category?
Els wrote:
Don’t know if you already solved this, but tags as attributes can only be used in 4.0.7 or higher. Otherwise you need a plugin (and use double quotes).
I’m running 4.0.8. Still haven’t found a solution for this issue.
Offline
Re: Filter by parent category?
alannie wrote:
I moved the code out of the article into a form… Still haven’t found a solution for this issue.
Ah, think I’ve figured it out. Does that article in which you use the original code have Use Texile as its Article Markup? If so, try setting that to Leave text untouched and see if it makes a difference. If it does and you want to use Textile in that article, surround your article_custom tag with double-equals characters to turn off textile processing or chuck it in a form like you did.
If that’s the case, quite why it didn’t render in your form is a mystery though. Works for me on my test install… unless I’m missing something obvious.
Last edited by Bloke (2009-08-03 15:48:53)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Online
Pages: 1