Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2009-01-30 22:26:34
- jeremywood
- Member
- Registered: 2007-12-12
- Posts: 26
Get article list by url_title
I’m interested in getting a list of articles, with a list of url_title’s as the input.
I.E. <txp:jer_url_tile_list input=“something-here, another-one” form=“list_form” />
I want to do this as a means to relate one article to another, but in a more human readable way than requiring our users to deal in article ID’s.
Our site uses short, easily understandable url_title’s, so this would be a good match for us.
We’d store the list in a custom field.
I’ve look at smd_query, but my poor human brain can’t figure out how to use it to accomplish this task.
Offline
Re: Get article list by url_title
How about:
<txp:article_custom wraptag="ul" break="li" limit="999">
<txp:title /><br /><txp:article_url_title />
</txp:article_custom>
That should output an unordered list of articles with their url title below it. You can, of course, change the markup or article_custom attributes as you need.
TXP Builders – finely-crafted code, design and txp
Offline
#3 2009-01-30 22:38:48
- jeremywood
- Member
- Registered: 2007-12-12
- Posts: 26
Re: Get article list by url_title
jakob:
That’s not the problem I’m trying to solve :-)
I want a specific article list, generated from a comma-delimited list of url_title’s.
Last edited by jeremywood (2009-01-30 22:41:00)
Offline
Re: Get article list by url_title
That’s not the problem I’m trying to solve :-)
Sorry, wasn’t so easy to guess. So, you want your users to put the article_url_title of (related) articles, comma-separated into a custom field? Then you want to generate a list of articles based on that?
Outputting a list of links is possible using smd_each to process the comma-separated list, but I’m not sure how you’d output the corresponding article titles or the articles themselves etc. as you first need to identify which ID belongs to which url_title in order to output all the article-related data with the standard tags. Sounds convoluted.
Hmmm, Maybe someone else has an idea?
TXP Builders – finely-crafted code, design and txp
Offline
#5 2009-01-31 00:17:21
- jeremywood
- Member
- Registered: 2007-12-12
- Posts: 26
Re: Get article list by url_title
jakob,
Thanks for pointing me at smd_each—that pushed me over the top to figuring out a solution for this myself.
It’s not the prettiest thing, but this is what I came up with:
<txp:variable name='related'>
<txp:custom_field name="RelatedProducts" />,
</txp:variable>
<txp:smd_each type="txpvar" include="related" subset="2">
<txp:smd_query query="SELECT *
FROM textpattern WHERE url_title = '{var_value}'">
<txp:permlink id='{ID}'><txp:permlink id='{ID}'/></txp:permlink>
</txp:smd_query>
</txp:smd_each>
I couldn’t figure out how to feed the contents of the custom field into smd_each directly, but used a variable as a workaround.
The nub of the thing is the line
<txp:permlink id='{ID}'><txp:permlink id='{ID}'/></txp:permlink>
I’ll be able to put that {ID} into whatever article form-list thing I might want.
Thanks again for the help.
Offline
Pages: 1