Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
<txp:mdm_if_category>
Not sure if there’s a better way to do this…
This plugin is used as such:
<pre>
<txp:mdm_if_category category=”…”>stuff goes here</txp:mdm_if_category>
</pre>
The category attribute is optional. If missing, the stuff always shows.
If category is the empty string <tt>”“</tt>, the stuff shows only if no category is current for the page.
If category is some other string, the stuff shows only if the current category name matches.
It’s simply a string based comparison, so it will probably break when true hierarchical categories are available; I’ll have to fix it then.
Here’s an example to give you a better idea of how it might work on a page:
<pre>
<ul>
<txp:mdm_if_category>
<li>will always display</li>
</txp:mdm_if_category>
<txp:mdm_if_category category=”“>
<li>displays only if no category selected</li>
</txp:mdm_if_category>
<txp:mdm_if_category category=“Mass Transit”>
<li>displays only if Mass Transit category selected</li>
</txp:mdm_if_category>
<txp:mdm_if_category category=“vx”>
<li>displays only if vx category selected</li>
</txp:mdm_if_category>
</ul>
</pre>
<a href=“http://www.splatbang.com/personal/mdm_if_category.txt”>Download it here.</a>
Last edited by mattmoss (2004-05-28 04:01:49)
Offline
Re: <txp:mdm_if_category>
> Is it not done or did you forget a link?
I’m stupid and forgot the link. Edited the original post and added the link.
Offline
#3 2004-05-28 19:30:43
- marco
- Member
- From: Montreal
- Registered: 2004-02-24
- Posts: 62
Re: <txp:mdm_if_category>
The download link does not work for me; all I get is this:
<?php
$plugin=‘YTo4OntzOjQ6Im5hbWUiO3M6MTU6Im1kbV9pZl9jYXRlZ29yeSI7czo2OiJhdXRob3IiO3M6MTQ6Ik1hdHRoZXcgRCBNb3NzIjtzOjEwOiJhdXRob3JfdXJpIjtzOjI1OiJodHRwOi8vd3d3LnNwbGF0YmFuZy5jb20vIjtzOjc6InZlcnNpb24iO3M6MzoiMC4xIjtzOjExOiJkZXNjcmlwdGlvbiI7czozOToiUGFzc2VzIGNvbnRlbnRzIGNvbmRpdGlvbmFsIG9uIGNhdGVnb3J5IjtzOjQ6ImhlbHAiO3M6MzI6IgoKCTxwPkV4dGVuZGVkIGhlbHA6IFRPRE88L3A+CgkKIjtzOjQ6ImNvZGUiO3M6MjIwOiIKCglmdW5jdGlvbiBtZG1faWZfY2F0ZWdvcnkoJGF0dHMsICRzbmlwKSB7CgkJJGNhdGVnb3J5ID0gbnVsbDsKCQlpZiAoaXNfYXJyYXkoJGF0dHMpKSB7CgkJCS8vIGV4dHJhY3RzICRjYXRlZ29yeSBpZiBwcmVzZW50CgkJCWV4dHJhY3QoJGF0dHMpOwoJCX0KCQlyZXR1cm4gKGlzX251bGwoJGNhdGVnb3J5KSB8fCBncHMoImMiKSA9PSAkY2F0ZWdvcnkpID8gJHNuaXAgOiAiIjsKCX0KIjtzOjM6Im1kNSI7czozMjoiZjBhZGYzOGMxNmQyOTc5ZDZiOTA0YjYyNDdiMGI4YzkiO30=’
?>
How do I download the actual file?
Offline
#4 2004-05-28 19:40:01
- Remillard
- Plugin Author
- From: Lenexa, KS
- Registered: 2004-05-16
- Posts: 169
Re: <txp:mdm_if_category>
The plugin is encoded. Save this as a text file and then upload to TXP.
Offline
#5 2004-05-28 19:53:19
- marco
- Member
- From: Montreal
- Registered: 2004-02-24
- Posts: 62
Re: <txp:mdm_if_category>
I see, I was expecting a zip file;
The help (?) in the TP back-end could have a one line help text insted of a blank popup….
Offline
#6 2004-05-30 21:25:49
- rajo
- Member
- Registered: 2004-03-13
- Posts: 43
Re: <txp:mdm_if_category>
can this tag accept a echo’d php variable as a string?
Offline
Re: <txp:mdm_if_category>
> can this tag accept a echo’d php variable as a string?
Ummmm….. I don’t know. =)
I’m more familiar with the data side of TXP and less the processing side. I don’t know how/when txp tags get processed in relation to overall php stuff. My gut instinct says it won’t work, but I have no basis nor evidence to back that up.
Best idea would be to try it?
Offline
#8 2004-05-31 07:31:33
- rajo
- Member
- Registered: 2004-03-13
- Posts: 43
Re: <txp:mdm_if_category>
okay thanks, I’ve been away from my installation of txp so I’ll be able to check it out in a few days, I think it probably won’t work either since most tags I’ve tried don’t seem to take them. Worth a shot though I guess.
Offline
#9 2004-05-31 22:59:03
- rajo
- Member
- Registered: 2004-03-13
- Posts: 43
Re: <txp:mdm_if_category>
I tried using this plugin as you had in your example (btw, as I thought echo’d variables didn’t). It doesn’t seem to be outputting anything even when I have it set up to check against each category in my site; if it fits the category I’m check ing against, I have it load a custom article list using that category. I’m using 1.18a with php 4.3.6 , apache on os x 10.3.4. Any ideas why it might not be working?
Offline
Re: <txp:mdm_if_category>
The most significant difference between your setup and mine is that I am still on textpattern 1.17. I’ll upgrade shortly and see if it breaks. If so, I’m an idiot. :) I’ll let you know how it goes.
Last edited by mattmoss (2004-06-01 04:38:37)
Offline