Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-11-02 14:33:43

matthijs
Member
Registered: 2008-12-15
Posts: 32

Conditional tag "if home"?

I have been looking for a simple conditional tag to check for the home page. Does that exist? Something like txp:if_home

I could try
<txp:if_section>

<txp:else />

<txp:if_section />

but that is not so elegant. Any ideas? Thanks!

Offline

#2 2009-11-02 14:39:54

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Conditional tag "if home"?

Hi

<txp:if_section name="">
home, sweet, home
<txp:else />
not home
</txp:if_section>

La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#3 2009-11-02 16:02:37

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Conditional tag "if home"?

matthijs wrote:

I could try

<txp:if_section>

<txp:else />

<txp:if_section />

but that is not so elegant. Any ideas? Thanks!

Seems elegant enough to me, if all you want is to test for the default section as opposed to the home page per se. If it’s the empty code block you find inelegant, try:

<txp:if_section name="default">
...
</txp:if_section>

If what you want is to test for the home page itself, i.e. the page you see at your site’s base URL, I have a plugin for you.


Code is topiary

Offline

Board footer

Powered by FluxBB