Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2020-09-05 18:08:22
- peterj
- Member
- From: Melbourne, Australia
- Registered: 2005-06-02
- Posts: 102
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
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
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
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: 102
Re: How to tell if I am on first article listing page
Yes – even simpler with NOT. I like this!
Offline
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