Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Filter by multiple categories
The tag compares category
(current or specified) against a list of name
s:
<txp:if_category category="apple" name="apple, banana, cherry" /> <!-- yes! -->
So
<txp:if_category name="apple, banana, cherry" />
checks whether the current category is in the list. But there is no current category on /category/apple/banana/
page, as we know.
Offline
Re: Filter by multiple categories
Ah of course. That could probably be clearer in the docs.
*adds it to the never-ending Todo list*
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
Offline
Re: Filter by multiple categories
Just revisiting this one with a tweak. From articles such as /section/title/some-cat, I’m extracting <page::url type="3">
(some-cat) into a variable (so I can test if it exists) and plugging this into article_custom to get all the products in that category:
<article::custom match="Category1=3" limit="999" sort="category1, category2">
...
</article::custom>
That’s fine and works a charm. What if I wanted to include articles that are in descendent (sub-)categories of the category given in the URL? Is that possible with some match
cleverness? Or do I need to pre-filter the passed value, build the category list as a comma-separated set, and then plug those into a regular article_custom tag. Viz:
<txp:variable name="list_of_cats"><category::list parent='<page::url type="3" />' children="1" break=","><txp:category /></category::list></txp:variable>
<article::custom match="category1" category='<txp:variable name="list_of_cats" />' limit="999" sort="category1, category2">
...
</article::custom>
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
Offline
Re: Filter by multiple categories
And one more thing, is there a tag-based way to output a nested category list using ul/li tags that mimics the Categories structure, given an arbitrary start point in the tree? I can’t see a way of finding out what ‘level’ we’re at without resorting to PHP and inspecting $thiscategory
.
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
Offline
Re: Filter by multiple categories
Bloke wrote #339739:
And one more thing, is there a tag-based way to output a nested category list using ul/li tags that mimics the Categories structure, given an arbitrary start point in the tree?
Valueless children
?
<txp:category_list parent="daddy" children wraptag="ul" break="li" />
Offline
Offline
Re: Filter by multiple categories
etc wrote #339740:
Valueless
children
?
Perfect. That needs documenting EDIT: Documented. Well, commited but it’s not showing on the docs site even though it’s allegedly deployed. Hmm…
etc wrote #339741:
Probably
<txp:article_custom depth ... />
Is that a 4.9 thing? Doesn’t seem to work on 4.8.8, and it’s not documented. Drat.
No biggie if so. I’ll stick with the longhand approach for now and upgrade to depth
when the site is upgraded. Thank you!
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
Offline