Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
#25 2004-06-11 14:33:58
- DougBTX
- Archived Plugin Author

- Registered: 2004-05-23
- Posts: 22
Re: <txp:mdm_if_category>
You could put “same code here” in a form and call that :)
I’m sure this could be added to the code though (catagory list; if you want to get fancy I’m sure a “not_category” tag could be set up too.)
Douglas
Offline
Re: <txp:mdm_if_category>
Trouble is, between those tags are <code><txp:article form=“lists” /></code> type stuff, so they couldn’t go into a form.
No worries, I’m fine with it as it is – ecstatic in fact! – but I wanted to check that there wasn’t a neater way of doing it.
Cheers,
Jon VC#9
Offline
Re: <txp:mdm_if_category>
Thus didst the mobs cry out, “Givest us feature X and we shall bestow upon thee the gold and fine wines.” And so didst he give them feature X, and they were joyful, yet upon installation of thus fine software product, they didst forget their promises.
Okay, enough crap. Here is version 0.3, which includes the features you guys wanted. You can list multiple categories (so “alpha,beta” is like “alpha OR beta”). You can also negate the query by prefixing with an exclamation mark (so “!alpha” is “NOT alpha” and “!alpha,beta” is “NEITHER alpha NOR beta”).
Also note that the use of “*” is gone… so if you were using that, please check the help for the plugin in the textpattern admin interface. All the options are explained in the help, hopefully clearly.
(Hmmm, Givest?? That can’t be correct…)
Offline
Re: <txp:mdm_if_category>
haha! Verily I say unto thee, thou art truly the man!
Just in case – my comment wasn’t a criticism or request for a change in the plugin. But hey! I’m not complaining – this is excellent, thanks again!
(I can’t manage fine wines and gold, but a link will be in order…)
Cheers,
Jon VC#9
Offline
Offline
Re: <txp:mdm_if_category>
There might be a bug (or a feature) because when I insert <txp:pfr /> inside the plugin code as shown below, it creates a broken link to <pre>http://www.mydomain.com/<txp:pfr />agentur/?c=Team</pre> which is not really what should be there.
<code><pre>
<txp:mdm_if_category category=“Leistungen”>
<li class=“active”><dfn>1.1: </dfn>Leistungen</li>
<li><dfn>1.2: </dfn><a href=”<txp:pfr />agentur/?c=Team” title=“Wer arbeitet bei anatom5?” class=“noNiceTitle” lang=“en”>Team</a></li>
<li><dfn>1.3: </dfn><a href=”<txp:pfr />agentur/?c=Kontakt” title=“So erreichen Sie uns” class=“noNiceTitle”>Kontakt</a></li>
</txp:mdm_if_category>
</pre></code>
This might also be related to my <a href=“http://forum.textpattern.com/viewtopic.php?id=2771”>earlier post</a> regarding this plugin and another one. Any hints or ideas?
Offline