Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#16 2004-09-11 13:23:21
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Plugin: If Section
> Maybe it’s not possible to have two if_section tags for the same section on one page?
This made me think and now I have this:
<code>
<div id=“koplinks”>
<txp:mdn_if_section section=“test1”>
<txp:output_form form=“koptest” />
</div>
<div id=“content”>
<txp:article section=“test1” form=“loremipsum” limit=“5” />
</txp:mdn_if_section>
<txp:mdn_if_section section=“test2”>
<txp:output_form form=“koptest” /></txp:mdn_if_section>
</div>
<div id=“content”>
<txp:article section=“test2” form=“loremipsum” limit=“5” />
</txp:mdn_if_section>
</div>
<code>
which seems to work fine.
Thank you Plaz for answering, I should have tried harder before asking.
Offline
Re: Plugin: If Section
Here’s a modification (well, actually, it’s a rewrite) of this plugin, so it can accept this kind of arguments:
<pre><txp:mdn_if_section section=“sec1, sec2, sec3, sec4”></pre>
(which means you can list all the section you want to trigger the output. nice if you have several groups of sections with similar content.)
And also:
<pre><txp:mdn_if_section notsection=“sec1, sec2, sec3”></pre>
(this should triger the output in every section except the ones you specified. very useful for displaying different content in you default category)
So what I did is modify the code a bit and when I got stuck, I asked a friend to rewrite it. What I have now is:
<pre>
function mdn_if_section($atts, $enclosed) {
if (!empty($atts[“section”])) {
$sections = explode(“,”, $atts[“section”]);
$sections[] = $GLOBALS[‘pretexs’][“section”];
return array_search($GLOBALS[‘s’], $sections) !== false ? $enclosed : “”;
} elseif (!empty($atts[“notsection”])) {
$sections = explode(“,”, $atts[“notsection”]);
return array_search($GLOBALS[‘s’], $sections) !== false ? “” : $enclosed ;
} else {
return “”;
}
}
</pre>
I was not sure if I’m about to post it as a separate plugin, but anyways… I hope this helps anyone…
ps: My first plugin! :)
pps: Well, it’s not written by me, but I inspired it!
Last edited by Boby Dimitrov (2004-10-01 16:01:15)
Offline
#18 2004-10-01 23:38:52
- Remillard
- Plugin Author

- From: Lenexa, KS
- Registered: 2004-05-16
- Posts: 169
Re: Plugin: If Section
Interesting. If you don’t mind, maybe I can incorporate that into the if section plugin as added functionality. Let me know.
Remillard
Offline
Re: Plugin: If Section
Oh, please do! I’m glad I can help!
Offline
#20 2004-10-04 22:47:43
- Andrew
- Plugin Author

- Registered: 2004-02-23
- Posts: 730
Re: Plugin: If Section
It’d be cool if the nomenclature would match up with that of mdm_if_category, that being:
<pre>
<txp:mdn_if_section category=”!Alpha”>
This will display provided the current section is not “Alpha”.
</txp:mdn_if_section>
</pre>
Rather than having section & notsection, why not just allow for a negation “!” Oh, and allowing for multiple sections is a good addition!
Last edited by compooter (2004-10-04 23:14:44)
Offline
Re: Plugin: If Section
Yes, that’s what I mainly needed – list of sections. But I chose to go with notsection as there’s a logical contradiction with the listing and the negation (!thing). Here’s what I mean… Consider the following code:
txp:mdn_if_section category=”!Alpha, Beta, !Gamma, Detla”
The logic I needed for notsection is show content for every other section except the listed. So the above, which reads more like “if it is not Alpha and is not Gamma, but it is Beta or Delta – show the content” was not working for me. So I chose to go with notsection.
Because if you want to instruct TXP to “if it is any other than Alpha – show the content” you’ll have to list all your sections, which is a bad solution.
Offline
#22 2004-10-07 16:46:34
- Remillard
- Plugin Author

- From: Lenexa, KS
- Registered: 2004-05-16
- Posts: 169
Re: Plugin: If Section
This plugin has been updated to version 2.0 based on the code offered by Boby Dimitrov (full credits in the plugin comments and help text as well, no worries). As usual, the plugin can be found at:
mdn_if_section.txt
Sorry for letting this go. I’ve had two design reviews in as many months, and all things textpattern have taken a very back seat. (I haven’t even attempted upgrading just yet, still running on the .19 version.)
Regards,
Remillard
Offline
Re: Plugin: If Section
This plug-in is not working for me.
:(
I have a clean installation of TXP 1.0 rc (with “clean” I mean that no plug-ins had been installed yet.)
When I activate the plug-in I’ve got the following parse error in all pages, even if I dont use the <txp:mdn_if_section> tag.
<code>
Parse error: parse error, unexpected $ in /home/midimidi/public_html/textpattern/publish.php(767) : eval()’d code on line 21
</code>
I want this plug-in, it’s an essential TXP plug-in, my first choosen plug-in!
Hope someone can help-me. Thanks.
<strong>Edit:</strong> I’m not getting the error with v1.0 of if_section plug-in.
This may help you, holy developers!
Last edited by maniqui (2004-10-14 01:21:13)
Offline
Re: Plugin: If Section
Not wanting to brag but my if_section plugin have had negate for some time now. But since this was the first of’em and now have implemented it too I’ll leave my plugin be and let it collect some more dust.
Plugins: ob1_advanced_search 1.032b, ob1_search_score 1.0, ob1_pagination 2.5, ob1_title 4.1, ob1_modified 2.1
“Let your plans be dark and as impenetratable as night, and when you move, fall like a thunderbolt.”
— Sun Tzu
Offline
#25 2004-10-14 02:49:18
- Remillard
- Plugin Author

- From: Lenexa, KS
- Registered: 2004-05-16
- Posts: 169
Re: Plugin: If Section
Well I’ve not upgraded to 1.0 as of yet, so I’m not certain if it’s a 1.0 specific problem. If it shows up on all pages, it seems to me like it may be.
I’ll start taking a look into it.
Regards,
Remillard
Offline
#26 2004-10-14 21:24:15
- Remillard
- Plugin Author

- From: Lenexa, KS
- Registered: 2004-05-16
- Posts: 169
Re: Plugin: If Section
I think there are a couple issues at work. At the very least, the returned output is not parsed for more textpattern tags, so that needs to change. Additionally, while compact code, it doesn’t exactly elaborate on what it’s doing. I think I’ll try to rewrite it in my own style (my own idiom, for MP fans out there). Maybe something will fall out of that.
The reason Version 1 probably works is that it’s so simple, it’d be hard for it to fail ;-).
I’m a bit closer I think.
Offline
#27 2004-10-14 23:59:14
- Remillard
- Plugin Author

- From: Lenexa, KS
- Registered: 2004-05-16
- Posts: 169
Re: Plugin: If Section
I’ve rewritten the plugin and I think it hangs together better now. I have replaced the 2.0 link at the top with the 2.1 version.
All functions are still the same. It’s thoroughly tested with g1.19 but I don’t have 1.0 to test it with. There’s nothing exotic in it now however.
Remillard
Offline
Re: Plugin: If Section
I have tested v2.1 of this simple and incredible plug-in and it seems to works fine!
At least, no parse errors yet!
Thanks you very much, Mr. Remillard
Offline
Re: Plugin: If Section
Does anyone have this working with rc3? I am having some problems with it outputing section specific forms for some reason.
Offline
#30 2005-05-05 20:53:57
- lee
- Member
- From: Normandy, France
- Registered: 2004-06-17
- Posts: 831
Re: Plugin: If Section
I do.
Offline