Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
if_section
Can you use <code><txp:if_section></code> without attributes in the same way as <code><txp:if_category></code>? As the default section does not appear in the URL of the page would the use of <code><txp:if_section></code> be the same as “if_not_frontpage”?
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#2 2005-11-26 17:23:08
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: if_section
I tried this:
<code>
<txp:if_section>
section <txp:section title=“y” />
</txp:if_section>
</code>
It doesn’t output anything, whether you are on a section frontpage or on an article page (that both have the section in the url)… :(
EDIT: This however:
<code>
<txp:if_section name=”“>
<txp:else />
section <txp:section title=“y” />
</txp:if_section>
</code>
does! Only on home page and category pages there is no output.
Last edited by doggiez (2005-11-26 17:28:40)
Offline
Re: if_section
Thanks Els. I know the “” usage for the front-page. I just wondered if the tag on it’s own without attributes worked in a similar fashion to the if_category tag. Apparently not. :(
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#4 2005-11-26 18:02:48
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: if_section
So I took it one step further and discovered that you can nest if_section and if_category:
<code>
<txp:if_section name=”“>
<txp:if_category>
article tag etc. for category list pages
<txp:else />
article tag etc. for home page
</txp:if_category>
</txp:if_section>
</code>
The (im)possibility to nest txp tags was the only reason left for me to keep using mdn_if_section.
Adding another txp:else, like this:
<code>
<txp:if_section name=”“>
<txp:if_category>
article tag etc. for category list pages
<txp:else />
article tag etc. for home page
</txp:if_category>
<txp:else />
something for all other sections
</txp:if_section>
</code>
was asked too much, unfortunately…
Offline
Re: if_section
Yeah. Some tags will nest OK, like you can use “if_excerpt” inside “if_article_list” with a double “else” tag for my favourite bit of coding, and others won’t. I’m not sure if there is any logic to it or whether it is arbitrary.
Last edited by thebombsite (2005-11-26 18:13:15)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#6 2005-11-27 02:22:56
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: if_section
You only cannot nest the same tag within itself, otherwise it’s fine, and you can go a couple levels deep (there’s no real limit, but I wouldn’t advise going crazy with it).
To this particular tag, <txp:if_section name="">
is the same as <txp:if_section>
. As doggiez pointed out, adding an else makes it “if we’re not on the front page”.
Offline
Re: if_section
Thanks Mary. I already knew about using “else”. My question was really just a simple “can it be used without an attribute?” like “if_category” but it appears not.
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#8 2005-11-27 12:55:20
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: if_section
mary wrote:
To this particular tag,
<txp:if_section name="">
is the same as<txp:if_section>
.
Ah, the same goes for <txp:if_category name="">
and <txp:if_category>
! Only for the if_category tag it means ‘any category’, and for the if_section tag ‘section default’. I was trying this use of if_category hoping that it would mean ‘no category’, but no luck… Which is not really a problem since adding txp:else gives the intended result.
Offline
#9 2005-11-28 01:44:33
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: if_section
Not quite: if_section always uses the name attribute, so it doesn’t matter whether you use it or not. if_category only uses the name attribute if it isn’t empty, otherwise it sees if $c is empty. It makes sense though: you’re always within a section ($s is always set); you’re not always within a category.
Offline
Pages: 1