Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: <txp:mdm_if_category>
Since it appears that the 1.19 release is just about ready, I’m going to hold off on upgrading to 1.18. Once 1.19 comes up, I’ll upgrade to that and retest mdm_if_category and get it working under 1.19.
Offline
#14 2004-06-02 19:55:45
- rajo
- Member
- Registered: 2004-03-13
- Posts: 43
Re: <txp:mdm_if_category>
thank you
Offline
Re: <txp:mdm_if_category>
Is there a way to modify this in order to become if_section?
Offline
Re: <txp:mdm_if_category>
> Is there a way to modify this in order to become if_section?
Probably like this:
<pre>
function mdm_if_section($atts, $snip) {
$section = null;
if (is_array($atts)) {
// extracts $section if present
extract($atts);
}
return (is_null($section) || gps(“s”) == $section) ? $snip : “”;
}
</pre>
But I haven’t tested it…
Offline
Re: <txp:mdm_if_category>
Thanks for helping, but I don’t think it works…
Offline
Re: <txp:mdm_if_category>
It probably is not working because if you just replaced the plugin text of mdm_if_category, then tp may not load it since it is not registered as mdm_if_section. I have an if plugin in the works that will work with most of the page related values.
Offline
Re: <txp:mdm_if_category>
This is very nice.
One request: the ability to handle the condition “show if any category is selected”. Perhaps by setting the category property to a space? Or some character that’s not allowed in Category names? Or, more simply, change the function of the first scenario — no category property is defined — to represent this condition.
Alternative take: implement an [else] tag, though I don’t know if that’s possible.
Offline
Re: <txp:mdm_if_category>
I just downloaded TXP 1.19 and decided to make sure the mdm_if_category plugin was still working.
So far, it seems to work. I haven’t tinkered with any of 1.19’s category changes yet, so that remains to be seen.
I added a bit of code so that if you use category=““, then the enclosed text will show when any category (except the empty category) is selected. That is, category=”” does the opposite of category=”“. (See earlier in this thread for an example of the latter.)
The plugin is at the same place as before
Offline
Re: <txp:mdm_if_category>
I’m sure that the answer to this is right in front of me, but I can’t track down the tag. This plugin should work perfectly to add a slightly-modified header to a page when browsing by category, as in <txp:mdm_if_category category="*">Browsing by CATEGORY</txp>.
But I can’t seem to find the tag to return the current category — not per article, because this is outside of the <txp:article ...> part of the page, but for the entire page.
Is this right in front of me? Thanks.
-Alan
Offline
Re: <txp:mdm_if_category>
If you look at the source code to mdm_if_category, you’ll see I call gps(“c”) which gets me the category name to compare against the category attribute.
However, that’s a PHP function call, and I don’t think you can simply drop that into your page template. I am not aware of any tag that gives you the current category name. It would require a plugin…
Offline
Re: <txp:mdm_if_category>
I just whipped up another plugin for what you wanted, <txp:mdm_category_name />; look for it in a separate forum thread by that name.
Offline
Re: <txp:mdm_if_category>
This is quality! Thanks for this useful plugin! I’ve ended up using this quite a lot!
At the moment I have 4 categories and I just want to separate one of the for special treatment. The other 3 all output the same content. At the moment I’ve listed each category like so:
<code>
<txp:mdm_if_category category=“special”>
different code here needs special treatment
</txp:mdm_if_category>
<txp:mdm_if_category category=“cat1”>
same code here
</txp:mdm_if_category>
<txp:mdm_if_category category=“cat2”>
same code here
</txp:mdm_if_category>
<txp:mdm_if_category category=“cat3”>
same code here
</txp:mdm_if_category>
</code>
Is there a smarter way to do this up? E.g, can you list categories in the attribute, separated by commas?
Cheers,
Jon VC#9
Offline