Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-07-08 19:55:38

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

soo_page_numbers: page counting and navigation widgets

Display page navigation widgets and information for article list pages. (Inspired by rsx_page_number, an old plugin from Txp’s early days.)

Information and download.

Version History

  • 0.4.2 (2020-03-09)
    • Fixed longstanding bug that used to be harmless but turned lethal in Txp 4.8.0
  • 0.4.1 (2017-03-10)
    • New URI handling algorithm, reverting to version 0.3 behavior, but as a freestanding plugin
  • 0.4.0 (2017-03-04)
    • Refactored to eliminate the requirement for an external library plugin. (NB: this means, inter alia, that the p (image ID) query parameter is no longer preserved in page links.)
  • 0.3.2 (2017-02-15)
    • Textpattern 4.6 compatibility update
  • 0.3.1 (2012-01-27):
    • soo_page_count (hence also soo_prev_page and soo_next_page) now preserve non-Txp query params for “next” and “prev” links.
  • 0.3.0 (2011-01-18):
    • Localisation for preformatted strings (e.g., “Page 1 of 2”), supporting 21 languages (thanks to txp community for translation help)
  • 0.2.7 (2010/2/11):
    • Fixed Textpattern notice about non-existent attribute when using soo_prev_page or soo_next_page (functionality not affected)
  • 0.2.6 (2009/11/23):
    • fixes a conflict with other context-dependent plugins by restoring the pg query parameter to its initial state
  • 0.2.5 (2009/10/21):
    • New attributes and shortcut tags for soo_page_count
  • 0.2.4 (2009/07/16):
    • Fixed showalways bug when an article list returns 0 pages (e.g. empty category)
  • 0.2.3 (2009/07/09):
    • Improved context check to prevent raw tag output
  • 0.2.2 (2009/07/09):
    • When both wraptag and break are set, non-linked text items (i.e., current page number or placeholder text) are no longer wrapped in span tags, and active_class is applied to the break element containing the current page number.
    • Both tags now do a context check and show nothing if the page is not an article list
  • 0.2.1 (2009/07/07)
    • Changed file name and one tag name
    • The showalways attribute of soo_page_count now also affects output when the article list is only one page
    • soo_page_links has also been given the showalways attribute
    • Scrapped soo_article_count, which was inherently buggy (as is the rsx_to_of it was based on)
  • 0.2 (2009/05/22): Not publicly released. Code overhaul, fixed to work with any query string
  • 0.1 (ages ago): Not publicly released, not very good either, just a sorry hack of what was probably a quick one-off plugin to begin with (it was early days for Txp).

Last edited by jsoo (2020-03-09 14:56:24)


Code is topiary

Offline

#2 2009-07-09 00:49:24

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

Re: soo_page_numbers: page counting and navigation widgets

Answering a question in this thread, at first glance it would probably be reasonable to not have the span added when there is both a wraptag and a break (talking about the soo_page_links tag). I think it’s important to have the span when there is no wraptag and the output is just a group of links (that’s how I tend to use it).

Alternately, I will consider adding an activetag attribute.

I’m not sure li as a wraptag makes sense. wraptag="ul" and break="li" would be the way to produce a list.

Also may not quite have understood the question — use class to add a class to the wraptag.

Last edited by jsoo (2009-07-09 00:56:40)


Code is topiary

Offline

#3 2009-07-09 00:58:55

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

Re: soo_page_numbers: page counting and navigation widgets

Sorry pal, I did in fact say wraptag=“li” in the other thread when I actually meant to say what you say above. Guess I’m more tired than I first thought :P

Soooo wraptag="ul" and break="li" is what I’m using. And therefore add the class to li, so for example: <li class="active">1</li> is what I’m hoping to do.

Last edited by driz (2009-07-09 01:01:56)


~ Cameron

Offline

#4 2009-07-09 01:21:10

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

Re: soo_page_numbers: page counting and navigation widgets

driz wrote:

And therefore add the class to li, so for example: <li class="active">1</li> is what I’m hoping to do.

That’s going to be trickier than I thought at first. I’m using Txp’s doWrap(), which does not leave me any way to apply the active class directly to the break tag.


Code is topiary

Offline

#5 2009-07-09 01:23:20

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

Re: soo_page_numbers: page counting and navigation widgets

Why not just have the plugin spit out a list by default like ob1_pagination does? and drop the wrap/break tags.

Also when your looking at a single article the tag shows itself instead of nothing; if you look here: http://blog.simplecandy.com/articles/hello-world the title tag shows the tag itself.

Last edited by driz (2009-07-09 01:25:28)


~ Cameron

Offline

#6 2009-07-09 01:37:30

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

Re: soo_page_numbers: page counting and navigation widgets

driz wrote:

Why not just have the plugin spit out a list by default like ob1_pagination does? and drop the wrap/break tags.

I see wraptag and break as standard attributes for any tag that produces a list of items. As I said, I like using this tag plain, no attributes. I’ll see if I can come up with another solution.

Also when your looking at a single article the tag shows itself instead of nothing; if you look here: http://blog.simplecandy.com/articles/hello-world the title tag shows the tag itself.

Heh — not so good. Easy fix, which I’ll bundle into whatever version comes out of all this discussion. If you want to make the edit now, in soo_page_count() replace the current global line with:

	global $is_article_list, $thispage;
	if ( ! $is_article_list ) return;

I should probably add the same context protection to soo_page_links.


Code is topiary

Offline

#7 2009-07-09 07:41:54

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

Re: soo_page_numbers: page counting and navigation widgets

I think it’s important to have the span when there is no wraptag and the output is just a group of links (that’s how I tend to use it)

How about make span the default wraptag unless replaced by another wraptag/break combination?


TXP Builders – finely-crafted code, design and txp

Offline

#8 2009-07-09 10:09:00

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

Re: soo_page_numbers: page counting and navigation widgets

jakob wrote:

How about make span the default wraptag unless replaced by another wraptag/break combination?

I had the same thought: v0.2.2 now available. The trick was getting active_class to apply in the latter case while still using doWrap(). I opted for a simple str_replace() on the output from doWrap().


Code is topiary

Offline

#9 2009-07-09 13:19:09

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

Re: soo_page_numbers: page counting and navigation widgets

:D Awesome, this works so brilliant. They should have something like this in the next TXP version. Thank you so so much.

EDIT

Found another bug, its the same as before, when using in the <title> tags its spitting out the actual tag when NOT viewing an article list and NOT viewing a single article.

The code I use for my Title site-wide is the following:

<title><txp:site_name /><txp:if_section name="default"><txp:else /> ~ <txp:section title="1" /></txp:if_section><txp:if_category> &raquo; <txp:category title="1" /></txp:if_category><txp:soo_page_count format=" / Page {current}" /><txp:if_individual_article> : <txp:title /></txp:if_individual_article><txp:if_search> : <txp:page_url type="q" /></txp:if_search><txp:tru_tags_if_tag_search> : <txp:tru_tags_tag_parameter striphyphens="lookup" /></txp:tru_tags_if_tag_search></title>

Last edited by driz (2009-07-09 15:26:41)


~ Cameron

Offline

#10 2009-07-09 15:46:04

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

Re: soo_page_numbers: page counting and navigation widgets

Thanks for the alert — this is a tricksier problem than I thought. I’ll look into it.

Edit: Temporary solution is to go back to putting a <txp:article pgonly="1" /> before it somewhere. Indeed, that may end up becoming the permanent solution — I may scrap the current method of having the tag return itself when $thispage hasn’t been set yet, hoping to be picked up again on a future resolved on the second trip through parse(), because as you’ve found sometimes that trip won’t happen resolve anything.

Last edited by jsoo (2009-07-09 18:02:44)


Code is topiary

Offline

#11 2009-07-09 18:03:23

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

Re: soo_page_numbers: page counting and navigation widgets

Well I’ve only been learning PHP properly for the last year, so I’m unable to help you. But I’ll be more than happy to test any updates that you have etc. Thanks for getting back to me so quick. Much appreciated.


~ Cameron

Offline

#12 2009-07-09 18:35:35

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

Re: soo_page_numbers: page counting and navigation widgets

I might have it — the key is using $pretext['secondpass'] to prevent the raw tag output you were getting. I’ll do some testing; if you’d like to join in, edit as follows — for each tag you want to test:

1. in the global declaration, replace $is_article_list with $pretext

2. remove the if ( ! $is_article_list ) line

3. in the line beginning

return '<txp:soo_page_links '

insert

$pretext['secondpass'] ? '' :

after the word return (leaving the rest of the line intact)


Code is topiary

Offline

Board footer

Powered by FluxBB