Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Dynamic "smart" list of section names
I’d like to create a variable (mostly for use in article_custom lists) that is a list of certain sections. And I’d like to not have to manually name those sections in the variable, as the list will grow over time to include more sections. As these relevant sections will all follow a naming convention, however, it seems reasonable to say something like:
“if section name begins with ‘issue-number-’ or ‘issue-special-’ list it here”
And get back “issue-number-1, issue-number-2, issue-number-foo, issue-number-bar, issue-special-cat, issue-special-dog”.
Any ideas or suggestions?
Offline
#2 2010-03-04 21:50:43
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Dynamic "smart" list of section names
If you don’t have too many other sections, you could use the exclude
attribute in section_list:
<txp:article_custom section='<txp:section_list exclude="your,other,sections" break="," />' />
If that is not an option, I assume one of the smd_ plugins can do it (smd_if, smd_query).
Offline
Re: Dynamic "smart" list of section names
Hmm, that backwards approach might work. Thanks, Els.
But that exact snippet does not work for me. And from the documentation, it seems that txp:section_list always returns a linked list, not just a list of names.
Offline
Re: Dynamic "smart" list of section names
floodfish wrote:
But that exact snippet does not work for me. And from the documentation, it seems that txp:section_list always returns a linked list, not just a list of names.
Not always, it can also return customized markup. Containers to rescue:
<txp:article_custom section='<txp:section_list exclude="your,other,sections" break="," wraptag=""><txp:section /></txp:section_list>' />
Offline
Re: Dynamic "smart" list of section names
Thanks Jukka! That worked.
Still remains to be seen if this defining-the-negative approach will be all I really need, but thanks for getting me this far.
I’m checking out the smd_ options …
Offline
Re: Dynamic "smart" list of section names
I got a helpful pointer from Uli over in the smd_if discussion . I ended up using smd_query as follows:
<txp:smd_query query="SELECT name FROM txp_section WHERE name REGEXP '^issue-'" break=",">
{name}
</txp:smd_query>
After a lot of failure getting that to parse directly as a txp:variable value, I just made it a form and am passing it around that way.
Offline
Pages: 1