Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-09-05 18:08:22

peterj
Member
From: Melbourne, Australia
Registered: 2005-06-02
Posts: 45

How to tell if I am on first article listing page

I’m just wondering if there is a smart way to use the snappy new txp:if_request to tell whether I am on a first listing page (pg=1). May have answered my question with the following, which seems to work. Is there a simpler way to handle this? 4AM brain fog…

<txp:if_request name="pg" type="get" match="pattern" value="[0-9]">
I'm on page 2 or more (as page 1 has no "pg" query)
<txp:else />
I'm on page 1
</txp:if_request>

Offline

#2 2020-09-05 18:57:42

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,721
Website

Re: How to tell if I am on first article listing page

peterj wrote #325805:

I’m just wondering if there is a smart way to use the snappy new txp:if_request to tell whether I am on a first listing page (pg=1)

Yes, perfect. And if you only want to know if you’re on the first page (and don’t care about the rest) then you can use not:

<txp:if_request name="pg" type="get" match="pattern" not value="[0-9]">
   I'm on page 1
</txp:if_request>

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 2020-09-06 09:01:59

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,367
Website

Re: How to tell if I am on first article listing page

Nice, havent seen txp:if_request!

If we can have a solution to affect the tested variable to a txp:variable we can get rid of adi_gps plugin!

Cheers.

Offline

#4 2020-09-06 11:30:37

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,721
Website

Re: How to tell if I am on first article listing page

Dragondz wrote #325810:

If we can have a solution to affect the tested variable to a txp:variable we can get rid of adi_gps plugin!

We do! You can use txp:page_url to grab any variable. Even remap it to other variable names in some tags. Or use tags-in attributes to import a URL var directly into a variable. See the examples on the docs site for the page_url and txp:variable tag.


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

#5 2020-09-06 13:42:30

peterj
Member
From: Melbourne, Australia
Registered: 2005-06-02
Posts: 45

Re: How to tell if I am on first article listing page

Yes – even simpler with NOT. I like this!

Offline

#6 2020-09-06 14:36:38

etc
Developer
Registered: 2010-11-11
Posts: 3,863
Website

Re: How to tell if I am on first article listing page

And even simpler than simple:

<txp:if_request not name="pg" type="get">
   I'm on page 1
</txp:if_request>

Offline

Board footer

Powered by FluxBB