Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-11-15 13:00:49

alesh
Member
From: Miami, FL
Registered: 2005-04-13
Posts: 228
Website

Do something on the homepage but nowhere else?

I am doing a bunch of stuff <txp:if_section name="" > foo <txp:else/> bar </txp:if_section> with the intent that foo will happen on the homepage and bar will happen everywhere else.

At the very least, foo also happens on the error_default 404 page. So, is there a conditional that will let me do stuff on the homepage only?


Yes, I have tried turning it off and on.

Offline

#2 2016-11-15 13:11:36

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Re: Do something on the homepage but nowhere else?

alesh wrote #302889:

is there a conditional that will let me do stuff on the homepage only?

Does if_status help?

<txp:if_status>
   <txp:if_section name="">
      foo
   <txp:else/>
      bar
   </txp:if_section>
<txp:else />
   // Error page
</txp:if_status>

The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2016-11-15 13:26:22

alesh
Member
From: Miami, FL
Registered: 2005-04-13
Posts: 228
Website

Re: Do something on the homepage but nowhere else?

Yep, that does it. Thanks!


Yes, I have tried turning it off and on.

Offline

#4 2016-11-15 14:50:08

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: Do something on the homepage but nowhere else?

This is the method I have used for years.

<txp:variable name="task" value="frontpage" />

<txp:if_category><txp:variable name="task" value="category" /></txp:if_category>

<txp:if_search><txp:variable name="task" value="search" /></txp:if_search>

<txp:if_author><txp:variable name="task" value="author" /></txp:if_author>

I always assign a different page to search section so I never have to check for <txp:if_section name="" >

Offline

Board footer

Powered by FluxBB