Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

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

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
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,793
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,254
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,254
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,793
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

#21 2009-07-09 00:50:22

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

Re: Page Number Help

driz wrote:

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)

I’ve answered in the support thread.


Code is topiary

Offline

#22 2015-11-04 15:53:49

Karsten
Member
From: Leiden, Netherlands
Registered: 2011-04-24
Posts: 47
Website

Re: Page Number Help

Hi, I’m using soo_page_numbers however, I have the following problem, the pagination links 1-2-3-4 >> links generated by the <txp:soo_page_links /> seem to include the full url www.mydomein.com/section/?pg=2

Is there is a way to link them simply to “/?pg=2” so that they also work if our website is loaded via a mirror.

Reason is that we use a mirror version of our site to be accessed by a certain proxy server. This proxy server doesn’t accept our main site (due to problems with our SSL) hence we simply made a mirror at mirror.mydomain.com.

However all pagination links refer not to mirror.mydomein.com/section/?pg=2 but to our main site mydomein.com/section/?pg=2 which makes that you break out of the mirror once you clink on any of the pagination links.

Suggestions anyone?

Offline

#23 2015-11-04 18:48:24

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,752
Website

Re: Page Number Help

Two ideas:

1) Edit the plugin. Actually it entails editing the library plugin soo_txp_obj or the soo_uri function if you copied that across manually.

At this line, replace:

$this->full = preg_replace('/\/$/', '', hu) . $this->request_uri();

with:

$this->full = $this->request_uri();

so that the domain is not prepended to the links to start with. (If the links lack a preceding slash, you might need to replace it with $this->full = "/" . $this->request_uri(); but I don’t think that is necessary).

2) Search and replace out the domain from the links after the link list has been generated using either rah_replace (txt installer):

<txp:rah_replace from="http://www.mydomain.com" to="">
	<!-- your tag -->
</txp:rah_replace>

or smd_wrap:

<txp:smd_wrap transform="replace|string|http://www.mydomain.com|">
	<!-- your tag -->
</txp:smd_wrap>

but I’m not sure how well those two perform for whole code blocks.

All untested but hopeful that one or the other or both work.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB