Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Page Number Help
Hi, I have the following code to show the Page Number:
<txp:chh_if_data> / Page <txp:page_url type="pg" /></txp:chh_if_data>
BUT this will only show the page number when your actively on a page like ?pg=2
What I want it to do is show the page number all the time (if their is more than one page), so for example:
domain.com/archives/ would be page 1
domain.com/archives/?pg=2 would be page 2
BUT if their is ONLY 1 page, then their would be no need to show the page number.
Thanks.
~ Cameron
Offline
Re: Page Number Help
What makes this a tricky request is the desire to show “Page 1” only when there are multiple pages — that means you can’t simply check for the presence of the pg
param in the URL query string and show “Page 1” if it isn’t set.
You could look into adapting rsx_page_number (or this revised version). I actually have my own revision of this plugin in private use and might be able to mod it to fit your purposes.
Or if you want to make your own php solution the variables to look for are in the $thispage
global: $thispage['pg']
and $thispage['numPages']
. You’d need to put the code after the relevant article
tag, or else stick in an extra article
tag with pgonly
.
Code is topiary
Offline
Offline
Re: Page Number Help
jsoo wrote:
Or there’s probably a reasonable solution using smd_if.
I like the idea of using simple solutions, any ideas on how I could do this using that plugin? Thank you
~ Cameron
Offline
Re: Page Number Help
I’m not an smd_if user, so I don’t know offhand how you get it to use a variable that is an item in a global array, namely $thispage['numPages']
.
Code is topiary
Offline
Re: Page Number Help
This might work:
<txp:php>
global $thispage;
if ( is_array($thispage) ) {
if ( $thispage['pg'] > 1 )
echo 'Page ' . $thispage['pg'];
elseif ( $thispage['numPages'] > 1 )
echo 'Page 1';
}
</txp:php>
Code is topiary
Offline
Re: Page Number Help
I use the plugin <txp:wet_if_page> (which is also nice if you have more than one stickies for only on the first page.)
In your case it would be this:
<txp:wet_if_page>
Page 1
<txp:else />
Page <txp:page_url type="pg" />
</txp:wet_if_page>
You can also use the ob1_pagination for this… Jonathan wrote this nice howto for a google style implementation of it.
Offline
Re: Page Number Help
aeonflux, wouldn’t that show “Page 1” even when the list is only one page long?
Code is topiary
Offline
Re: Page Number Help
jsoo wrote:
aeonflux, wouldn’t that show “Page 1” even when the list is only one page long?
Oops you are right I totally misunderstood (i.e. did not read carefully ;) it should be this then:
<txp:wet_if_page>
<txp:else />
Page <txp:page_url type="pg" />
</txp:wet_if_page>
Offline
Re: Page Number Help
Well I WANT it to show Page 1, but only if their are pages. ie 1,2,3
So for example look at this test site: http://blog.simplecandy.com/articles/ we are on page 1 so I want it to show page 1 and then page 2 etc in the title, because they’re will be more than one page of content.
BUT if I was on a part of the site that did not have more than one page (such as an about page) they’re would be no need to tell the user they on page 1 because they’re would be only one page of articles to show anyways.
So this is what I’m wanting:
http://blog.simplecandy.com/articles/ TITLE would be Page 1
http://blog.simplecandy.com/articles/?pg=2 TITLE would be Page 2
Everyone with me? :P
Also
By default when you use the native textpattern tags <txp:newer /> etc when you go back to page 1 it WILL not add the ?pg1 to the url instead it will go back to original url, but ob1 pagination does not do this? How can I fix it? Thanks
Last edited by driz (2009-07-06 22:04:57)
~ Cameron
Offline
Re: Page Number Help
Did you try the raw php snippet I posted above? A one-minute test on my end shows that it indeed works as you want.
As to ?pg=1
, what is it you want to fix? Have ob1_pagination
match the behavior of newer
/@older@, or vice versa?
Code is topiary
Offline
Re: Page Number Help
Yes I would like for ob1_pagination match the behaviour of newer/older. In other words …/section/?pg=1 should be …/section/
And the PHP script you kindly provided did not work as desired. Just to clarify what I mean:
../section/
This would have the title SECTION NAME – PAGE 1
../section/?pg=2
This would have the title SECTION NAME – PAGE 2
At the moment TXP will only show the page number IF their is a pg=#
in the URL.
BUT I only want it show a page number in the tile IF their are pages, NOT if their is just one page.
Hope this clears things up thanks.
Last edited by driz (2009-07-08 13:21:04)
~ Cameron
Offline