Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-11-15 15:18:13

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

detect front page of section

I am trying to detect the front page of a section and the code does not seem to work. Am I using the wrong parameter for the variable?

<txp:variable name="front"><txp:page_url type="pg" /></txp:variable>
<txp:if_variable name="front" value="">
<txp:article status="sticky" limit="20" />
<txp:else /></txp:if_variable>
<txp:article limit="10" />

What I would expect to see from the above is sticky articles in the beginning of the section’s front page, then 10 live articles.
On the other pages of the section’s list of articles I am indeed getting the articles as expected.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#2 2018-11-15 17:13:28

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: detect front page of section

What does <txp:page_url type="pg" /> give you if you use it on its own on the desired page?

Phil uses the equivalent of <txp:if_variable name="front" value="1"> in the four-point-seven theme here.


TXP Builders – finely-crafted code, design and txp

Offline

#3 2018-11-15 17:48:38

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

Re: detect front page of section

Yes, use value="1" to test.

Alternatively, in 4.7+ this might do something similar without the variable dance:

<txp:if_article_list>
   <txp:evaluate query='<txp:page_url type="pg" /> = 1'>
      <txp:article status="sticky" limit="20" />
   </txp:evaluate>
   <txp:article limit="10" />
</txp:if_article_list>

Note the <txp:if_article_list>, otherwise you’d see the same behaviour on an individual article page because pg is set to 1 there too. Of course, if you have a different template serving the landing page vs individual articles, you can omit the wrapped conditional.

Last edited by Bloke (2018-11-15 17:51:08)


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

#4 2018-11-15 17:51:53

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: detect front page of section

On the rescue again!!! Thanks so much Julian. That did the trick.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#5 2018-11-15 18:18:35

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: detect front page of section

Sorry Stef,

I just saw your post. Thank you too.

ps… edited to add that I am really getting to like the eavluate tag!

Last edited by colak (2018-11-15 18:40:03)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB