Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-03-04 19:47:30

floodfish
Member
From: Brooklyn, NY
Registered: 2007-01-11
Posts: 155
Website

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

#3 2010-03-04 22:50:56

floodfish
Member
From: Brooklyn, NY
Registered: 2007-01-11
Posts: 155
Website

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

#4 2010-03-04 23:09:47

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

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

#5 2010-03-06 00:36:24

floodfish
Member
From: Brooklyn, NY
Registered: 2007-01-11
Posts: 155
Website

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

#6 2010-03-06 05:19:26

floodfish
Member
From: Brooklyn, NY
Registered: 2007-01-11
Posts: 155
Website

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

Board footer

Powered by FluxBB