Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How to return a category list but without using the cateogry list tag?
Basically I want to populate a select menu with categories.
i.e.
<select>
<option>Category 1</option>
<option>Category 2</option>
<option>Category 3</option>
<option>Category 4</option>
<option>Category 5</option>
</select>
The Textpattern category_list tag returns a list of categories wrapped in anchors, which is useless in this instance.
Any ideas how to return a simple text string or list of categories, using a plugin, php or otherwise?
Many thanks.
Offline
Re: How to return a category list but without using the cateogry list tag?
<select><option><txp:php>
echo join('</option> <option>', doSpecial(safe_column('title', 'txp_category', '1=1 ORDER BY title ASC')));
</txp:php></option></select>
Last edited by ruud (2007-07-05 14:48:20)
Offline
Re: How to return a category list but without using the cateogry list tag?
Excellent. Thanks Ruud – I’ll give that a go.
Offline
Re: How to return a category list but without using the cateogry list tag?
One further question – I should have mentioned in my first post.
I also need to populate the value of each option with the category title. The above also returns ‘root’ as the final category – any way to leave that out?
E.g. the code Ruud posted returns;
<select><option>Category 1</option><option>Category 2</option><option>root</option></select>
And I need it to return;
<select><option value="Category 1">Category 1</option><option value="Category 2">Category 2</option></select>
Thanks again for any help.
Offline
#5 2007-07-08 23:39:04
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: How to return a category list but without using the cateogry list tag?
<select><option><txp:php>
echo join('</option> <option>', doSpecial(safe_column('title', 'txp_category', 'name != "root" ORDER BY title ASC')));
</txp:php></option></select>
Last edited by Mary (2007-11-17 07:20:26)
Offline
#6 2007-11-17 06:09:28
- mhulse
- Plugin Author
- From: Eugene Oregon
- Registered: 2005-01-21
- Posts: 200
Re: How to return a category list but without using the cateogry list tag?
Thanks to ruud and Mary for being so helpful. :)
Last edited by mhulse (2007-11-27 18:38:58)
Offline