Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2004-06-08 21:44:53

Remillard
Plugin Author
From: Lenexa, KS
Registered: 2004-05-16
Posts: 169

Plugin: If Section

Well I’m in a PHP plugged in mood today. Based on a question in the HDI? forum, I made another plugin.

Current Version: 2.1
mdn_if_section.txt-2.1

You give it a section=“sectionname” parameter and if you have a match, the enclosed text is output.

As of version 2.0, the plugin also supports multiple sections in the form of a comma separated list. Additionally as of 2.0, the plugin supports the notsection parameter. If the current section is NOT in the list of sections, then the enclosed text will be output.

As of version 2.1, hopefully it’s less buggy. Additionally, the output text is now parsed, so it may contain TXP tags and have them rendered.

If for whatever reason you need to use version 1.0, it can be found at mdn_if_section_1.0.txt

Version 2.0 is not available as it buggy.

Regards,
Remillard

Last edited by Remillard (2004-10-15 00:34:38)

Offline

#2 2004-06-08 22:57:16

tinyfly
Member
From: Dallas, Texas
Registered: 2004-05-10
Posts: 462
Website

Re: Plugin: If Section

So it is not supposed to output anything if I am not on that section? If this is correct it doesn’t work for me. It is outputing whatever is between the tags no matter what section I am on.

Offline

#3 2004-06-08 23:16:32

Remillard
Plugin Author
From: Lenexa, KS
Registered: 2004-05-16
Posts: 169

Re: Plugin: If Section

Rats. I’ll take a look. Essentially that’s what it’s supposed to do though. I’ll do some testing and see if I can reproduce the trouble.

Offline

#4 2004-06-08 23:25:24

Remillard
Plugin Author
From: Lenexa, KS
Registered: 2004-05-16
Posts: 169

Re: Plugin: If Section

Well, I poked around with it but it still works.

Here is the code I used for testing:
<code>
This is a test of the if_section tag.<br/> <txp:mdn_if_section section="testpage"> You have reached the test page! </txp:mdn_if_section><br/> <txp:mdn_if_section section="testpage2"> You have reached the 2nd test page! </txp:mdn_if_section><br/>
</code>

You can see it in action at testpage and testpage2. EDIT: 2004.10.07 – I took out the hyperlinks here as the pages these went to are long gone. Look at the bottom and you should see the lines display based on section context.

However, this doesn’t solve your problem.

Could you post the section of code that you are trying to make come through, and your section names and so on?

Last edited by Remillard (2004-10-08 00:08:17)

Offline

#5 2004-06-08 23:56:49

tinyfly
Member
From: Dallas, Texas
Registered: 2004-05-10
Posts: 462
Website

Re: Plugin: If Section

<code><txp:mdn_sectionlink section=“portfolio”>Portfolio</txp:mdn_sectionlink> &#187;
<txp:mdn_sectionlink section=“largescale”>Large Scale</txp:mdn_sectionlink></code>

Sorry, I am using the sectionlink plugin not the if_section plugin. I Guess I was trying to use it for something else.

Offline

#6 2004-06-08 23:58:54

Remillard
Plugin Author
From: Lenexa, KS
Registered: 2004-05-16
Posts: 169

Re: Plugin: If Section

Not a problem. I got a little prolific today and they have very similar themes. I hope it works when you get it switched!

Remi

Offline

#7 2004-06-11 13:05:02

candela
New Member
Registered: 2004-05-17
Posts: 6

Re: Plugin: If Section

Thanks Remillard for this plugin. That’s what I need.

candela

Offline

#8 2004-06-15 00:50:38

Plaz
Member
From: Minnesota
Registered: 2004-06-02
Posts: 33

Re: Plugin: If Section

Hey- This works very well.

I also discovered that you can have your section-specific content appear on the default page by using:
<code>

<txp:mdn_if_section section=“default”> You are at the home page of the content…. the default section for textpattern… These are all the articles.</txp:mdn_if_section>

</code>

For instance, allof my txp content is in a subdirectory called /content/

If a user goes to : www.site.com/content/ they will see:

You are at the home page of the content…. the default section for textpattern… These are all the articles.

If they go to a differnet section like:

www.site.com/content/cats

They will see the section-specific content for that section only.

GREAT JOB!!

Last edited by Plaz (2004-06-15 00:57:20)


If you want something you have never had, then you must be willing to do something you have never done.

Offline

#9 2004-06-15 02:21:04

Remillard
Plugin Author
From: Lenexa, KS
Registered: 2004-05-16
Posts: 169

Re: Plugin: If Section

well to be honest, some of that is the default TXP behavior I think. Say you create your defaultpage template, and then also assign two sections to that page template. Your default page (index) will have content from Section 1 and Section two on the default page template. If you go to Section 1, the same page will load, but the content context will be Section 1, so only Section 1 content will show. Likewise for if you go to Section 2, same thing.

The plugin was mostly created for non-article content, bits of static or mostly static text on pages that ALSO needed to have section context. Say Section 2 needed a special addition of a list of links. You could put if_section around that and then on the default page and section 1, you wouldn’t get the links, but on section 2 they would display.

Works best if you have one page template that just needs a little tweaking and doesn’t warrant creating a completely different page template.

But, I’m glad you like it :)

Thanks
Remillard

Offline

#10 2004-06-15 15:13:18

Plaz
Member
From: Minnesota
Registered: 2004-06-02
Posts: 33

Re: Plugin: If Section

Yes. That is exactly how I am using it.
I had all sections assigned their own page template… so that I could have section-specific content at the top of each section- and then each section lists only it’s own articles. It was working well, but annoying to update several templates that looked identical except for the little chunk of content at the top.

With your plugin, I switched things so that all pages use the same default page template, but display the section-specific content at the top of the page, and then list only that sections articles.

This makes things much easier because I can edit one page template instead of 7 every time I want to change something.

Always a good idea to be able to re-use code/pages/etc.

Thanks for a great / much needed plugin!


If you want something you have never had, then you must be willing to do something you have never done.

Offline

#11 2004-06-15 15:21:08

tinyfly
Member
From: Dallas, Texas
Registered: 2004-05-10
Posts: 462
Website

Re: Plugin: If Section

Also, don’t forget about the output_form tags which are like txp’s includes. I have multiple page templates but when I want to update the header in all the templates I just have to update the form “header_form” because I put this tag in all my page templates:
<code><txp:output_form form=“header_form” /></code>

Offline

#12 2004-08-17 21:59:06

Plaz
Member
From: Minnesota
Registered: 2004-06-02
Posts: 33

Re: Plugin: If Section

That is a very good idea.

All of the sections for this site use the If_Section plug-in:

NorthWoodsKitchen.com

and all sections use the default page to display their content… so if you go to:
northwoodskitchen.com/content
you get a list of all articles. Any specific section like:
northwoodskitchen.com/content/eat
serves up the content for that section only.

Great plug-in… very useful.


If you want something you have never had, then you must be willing to do something you have never done.

Offline

Board footer

Powered by FluxBB