Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2009-07-07 21:21:18

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,781
Website

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

#12 2009-07-08 13:05:45

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

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 NAMEPAGE 1

../section/?pg=2
This would have the title SECTION NAMEPAGE 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

#13 2009-07-08 13:45:56

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,781
Website

Re: Page Number Help

driz wrote:

Hope this clears things up thanks.

Yes and no. Certainly the PHP snippet I wrote will not output the section name. (You could easily add that using <txp:section />.) But it does show “Page 1” on the first page of a multi-page list, and nothing if the list is only one page long, just as you requested. Right?

Haven’t looked at the code for ob1_pagination but it should be a simple mod to get the behavior you want.

Alternately, I’ll see about releasing my pagination plugin, which will solve all these issues (more or less; I’m sure my “Google-style” nav widget is not identical to ob1’s). Might get to this later today.


Code is topiary

Offline

#14 2009-07-08 14:39:50

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: Page Number Help

The PHP script didn’t output anything for me. I did it like this:

<title>The Blog / <txp:section /><txp:php>
global $thispage;
if ( is_array($thispage) ) {
   if ( $thispage['pg'] > 1 )
      echo ' &mdash; Page ' . $thispage['pg'];
   elseif ( $thispage['numPages'] > 1 )
      echo ' &mdash; Page 1';
}
</txp:php></title>

But all I get is just the section name being output and then nothing :/ I have all the PHP options turned to Yes in Preferences

Last edited by driz (2009-07-08 14:43:37)


~ Cameron

Offline

#15 2009-07-08 16:24:36

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,781
Website

Re: Page Number Help

My mistake — the code will only work if it follows a <txp:article /> tag somewhere on the page.

Edit: Yep, MattD has it right.

Last edited by jsoo (2009-07-08 16:38:35)


Code is topiary

Offline

#16 2009-07-08 16:32:22

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,251
Website

Re: Page Number Help

The php snippet along with an article tag using pgonly should get you the results you want.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#17 2009-07-08 17:15:57

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: Page Number Help

You want me to put <txp:article pgonly="1" /> before the PHP code inside the <title> tags? I just tried that and nothing happens :/


~ Cameron

Offline

#18 2009-07-08 17:38:51

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,251
Website

Re: Page Number Help

Are you using the same article tag as you are to display the articles? I just added this to my site and it works.

<txp:article limit="6" pgonly="1"/>

<title><txp:page_title /> <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>
</title>

EDIT: this also works for me

<title><txp:article limit="6" pgonly="1"/><txp:page_title /> <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>
</title>

Last edited by MattD (2009-07-08 17:45:00)


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#19 2009-07-08 20:01:27

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,781
Website

Re: Page Number Help

Now there’s this plugin as a solution.

<txp:soo_page_count format="Page {current}" />

Doesn’t require the <txp:article pgonly="1" /> tag.


Code is topiary

Offline

#20 2009-07-08 23:33:58

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: Page Number Help

Awesome mate works great. Thank you so much for this awesome plugin.

EDIT: I hate to be a pain :D but I hate the fact that it adds a <span> inside the wraptag. I use a <li> for the wraptag. How would I go about making the active_class add the class to the wraptag? Thanks. (Ive had a look at the PHP but I’ll just end up breaking it)

Last edited by driz (2009-07-08 23:47:26)


~ Cameron

Offline

Board footer

Powered by FluxBB