Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#13 2004-09-10 23:37:01
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Plugin: If Section
Is it not possible to put txp:article tags inside the txp:mdn_if_section tags? I can use output_form, and linklist, but when using article tags weird things start to happen…
Offline
#14 2004-09-11 00:34:46
- Plaz
- Member
- From: Minnesota
- Registered: 2004-06-02
- Posts: 33
Re: Plugin: If Section
Here is how I did it.
This is one of the If_Section areas that I have listed on my default page. I have a listing like this for each of my sections.
After my section specific content and the table that holds it ends… then the content for that section begins:
<code>
<!— DRINK SECTION HEADER —>
<txp:mdn_if_section section=“drink”><table width=“75%” border=“0” cellspacing=“0” cellpadding=“0” align=“center”><tr><td>
<p class=“OrangeArticleTitle” align=“center”>DRINK</p>
<p align=“left”>Drink! Pairing food with wine and other assorted libations.You can click right through to the beverage forums or check out the insightful articles below…<p>
<p align=“right”><a href=“http://www.northwoodskitchen.com/forums/index.php?c=2” class=“orangelinks”>Discuss It In The ‘Drink’ Forums>></a></p><td></tr></table><txp:article form=“articles” limit=“100” /></txp:mdn_if_section>
</code>
My articles form looks like this:
<code>
<txp:if_article_list>
<P class=“ArticleTitle” align=“left”><txp:permlink><txp:title /></txp:permlink></p>
<div align=“left”><P>By: <txp:author /><BR><txp:posted /></P></div>
<div align=“left”><P><txp:excerpt /></P></div>
<P><div align=“center”><txp:permlink>Full Article >></txp:permlink><BR><img src=“http://www.northwoodskitchen.com/images/fluer1.gif” width=“30” height=“23”></div></P>
</txp:if_article_list>
<txp:if_individual_article>
<P class=“ArticleTitle” align=“left”><txp:permlink><txp:title /></txp:permlink></p>
<div align=“left”><P>By: <txp:author /><BR><txp:posted /></P></div>
<div align=“left”><P><txp:body /></P></div>
<P><div align=“center”><img src=“http://www.northwoodskitchen.com/images/fluer1.gif” width=“30” height=“23”> </div></P>
</txp:if_individual_article>
</code>
This way if they just go to the main section, they get the list of all of the article excerpts. If they click on one of the excerpts, then they get the full article.
(Pardon my site specific css and formatting…)
Does that help? I hope I explained everything correctly….
Last edited by Plaz (2004-09-11 00:46:23)
If you want something you have never had, then you must be willing to do something you have never done.
Offline
#15 2004-09-11 13:03:01
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Plugin: If Section
This is how I did it and what happens:
I created a section test1 and a section test2, both using the same page template. Both sections have 2 articles.
Have a look at <a href=“http://www.doggiez.nl/test1/”>test1</a>.
On my page in the yellow bordered box I have just this:
<code>
<div id=“koplinks”>
<txp:mdn_if_section section=“test1”>
<txp:output_form form=“koptest” /></txp:mdn_if_section>
<txp:mdn_if_section section=“test2”>
<txp:output_form form=“koptest” /></txp:mdn_if_section>
</div>
</code>
The form “koptest” only contains a bit of text, and displays as it should in section test1.
In the gray box is this code:
<code>
<div id=“content”>
<txp:mdn_if_section section=“test1”><txp:article section=“test1” form=“loremipsum” limit=“5” /></txp:mdn_if_section>
<txp:mdn_if_section section=“test2”><txp:article section=“test2” form=“loremipsum” limit=“5” /></txp:mdn_if_section>
</div>
</code>
The two articles of section test1 display as they should.
BUT: now have a look at <a href=“http://www.doggiez.nl/test2/”>test2</a>.
There where the same text should be as in test1, one article of section test2 appears. There is no article tag there at all!
And where the articles should be, is nothing…
Maybe it’s not possible to have two if_section tags for the same section on one page?
Offline
#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