Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
How to grab that last bit.
For some reason I seem to think that there was one of those hidden-away, not-much-talked-about txp tags that picked this up but actually just a bit of PHP that I can stick between 2 tags would be great.
You know when you are viewing an article list and you click on the older or newer buttons the URL changes to reflect the page so you get an ?pg2 or ?pg8 at the end? How can I grab that and without the preceding slash please?
Last edited by thebombsite (2008-10-29 18:42:47)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: How to grab that last bit.
You can use the $thispage
array. If you put:
<txp:php>
global $thispage;
dmp($thipage);
</txp:php>
you can examine the array. Specifically you can use $thispage['numPages']
and $thispage['pg']
to obtain what you want. Older:
<txp:php>
global $thispage;
if ($thispage['pg']<$thispage['numPages']) {
echo "?pg=".($thispage['pg']+1);
}
</txp:php>
Newer:
<txp:php>
global $thispage;
if ($thispage['pg']>1) {
echo "?pg=".($thispage['pg']-1);
}
</txp:php>
Hope this helps.
Offline
#3 2008-10-29 21:38:54
- rsilletti
- Moderator
- From: Spokane WA
- Registered: 2004-04-28
- Posts: 707
Re: How to grab that last bit.
This has some tags that return just the numbers if that is all you want.
Offline
#4 2008-10-29 23:07:23
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How to grab that last bit.
<txp:page_url type="pg" />
Offline
Re: How to grab that last bit.
Damn it Els, I knew there was a tag. How are we supposed to remember all this? :)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#6 2008-10-30 16:25:49
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How to grab that last bit.
I study Textbook every night before I go to sleep for half an hour.
Edit: forgot the ;)
:)
Last edited by els (2008-10-30 16:27:40)
Offline
Re: How to grab that last bit.
And I go to bed with questions from this forum rattling around in my head. Sad isn’t it? ;)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Pages: 1