Textpattern CMS support forum

You are not logged in. Register | Login | Help

#21 2010-05-06 21:09:46

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,620
Website

Re: List pagination

thebombsite wrote:

So pray tell where <txp:scope> might pop up then.

*shrug* ask Sam, he proposed it. I just work here :-)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#22 2010-05-10 23:55:49

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,620
Website

Re: List pagination

Minor adjustment to the opening post and the download:

  • Changed ctype to context in line with latest SVN commit
  • Added escape attribute (default: html)
  • Added <txp:if_pages> as a convenience to allow you to wrap the entire nav block so it only appears when there is > 1 page of results

I’ve had no luck with the ‘gap’ thing. I tried adding prev_gap and next_gap items but if you use them separately you need to remember to kep the range attributes in step, which is a bind.

If instead they are automatically added to the existing prev and next items then you lose the ability to alter the character used/set escaping (by default it’d be &hellip; which would require escape=""… again, not a very user friendly solution). You also lose the ability to turn them off unless a new attribute is introduced, which would only be applicable to the next and prev items. It’s bad enough having range which is only applicable to next and prev, without introducing more attributes for the sake of it.

Investigation ongoing. Perhaps this really is plugin territory, or a rethink of the way it’s implemented here. Any help/ideas appreciated.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#23 2010-05-12 17:26:53

mwr
Member
From: Canada
Registered: 2006-01-31
Posts: 159
Website

Re: List pagination

How about a popup menu that allows you to jump directly to a page — as seen at the bottom of this site.


Mark

Offline

#24 2010-05-13 00:00:42

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,620
Website

Re: List pagination

mwr wrote:

How about a popup menu that allows you to jump directly to a page

Good idea, and actually the original pagination tag was most of the way there already. I’ve just added a convenience item="all" that gets all the page numbers. The tricky thing here is to get it to select the current page in the list. The paging tag can’t do that, and it’s rather tough to put it in there without making things much more complicated. A fairly simple alternative is to get the tag to do the HTML part and then throw some jQuery on the page to position the current page in the select list:

<form action="">
   <select name="pg" id="jumpto">
      <txp:paging item="all" break="option" link="0" />
   </select>
   <input type="submit" value="Jump to page">
</form>

<script type="text/javascript">
jQuery(function() {
   var currpage = '<txp:paging item="page" link="0" />';
   jQuery("#jumpto option").each(function() {
      if (jQuery.trim(jQuery(this).text()) == currpage) {
         jQuery(this).attr("selected", true);
      }
   });
});
</script>

If it weren’t for the fact you can’t add a ‘name’ attribute to the paging tag (at the moment), you could generate the entire <select> in one line instead of having to type some HTML as well. Of course, if you prefer an onchange selector you can do that instead of the submit button. The jQuery just grabs the current page, iterates over the options list and finds the one that matches. I’m sure there’s a more efficient way of doing that but jQuery’s not my bagel.

Hope that helps somewhat. If anybody has any comments on this method please share them.

Everyone

The latest version of the tag suite has the following changes:

  • New all item, as mentioned above
  • New attribute separator. This is the text you want to use to visually separate the central prev/next paging area from its anchored numbers either side. The example below shows how you could use it
  • New conditional if_page that takes the attribute value. This allows you to test if you are on any given page. Provide one or more pages as a list and it’ll take action if the current page number matches one of them. Supports <txp:else />

Here’s an example using the new separator attribute and a frivolous use of <txp:if_page>:

<p class="direct_nav">
<txp:paging item="first" linktext="First" />
<txp:newer showalways="1">&laquo;</txp:newer>
<txp:paging item="prev" break="&nbsp;" separator="&hellip;&nbsp;" />
<txp:paging item="page" link="0" /><txp:if_page value="5"> HELLO </txp:if_page>
<txp:paging item="next" break="&nbsp;" separator="&nbsp;&hellip;" />
<txp:older showalways="1">&raquo;</txp:older>
<txp:paging item="last" linktext="Last" />
</p>

On page 6, that would render the following:

First « … 4 5 6 7 8 … » Last

Let me know if this is a better/worse/more confusing/useless alteration, or any other random related thoughts you may have.

Last edited by Bloke (2010-05-13 00:33:11)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#25 2012-01-19 05:28:07

ax
Member
From: Germany
Registered: 2009-08-19
Posts: 149

Re: List pagination

I don’t get it. When trying this:

<txp:category_list type="image" />
Results: <txp:paging item="result_total" />.
Page <txp:paging item="page, pages" break=" of " link="0" />
<txp:paging item="prev, page, next" break=" &middot; " wraptag="div" class="direct_nav" range="3" />

then nothing happens. Tag trace shows:

<txp:category_list type="image" />
	[SQL (0,00036406517028809): select name, title from txp_category where type = 'image' and name not in('default','root')   order by name ASC]
<txp:paging item="result_total" />
<txp:paging item="page, pages" break=" of " link="0" />
<txp:paging item="prev, page, next" break=" &middot; " wraptag="div" class="direct_nav" range="3" />

What am I missing?

Offline

#26 2012-01-19 13:14:32

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,620
Website

Re: List pagination

ax wrote:

I don’t get it… nothing happens.

I’d forgotten all about this mod. Without trying it again, I guess nothing happens because it’s not been tested on the latest Txp version. This was written a looooong time ago.

But then again I can’t recall anything in the code that would stop it from working under 4.4.1. Perhaps it’s time to look at this again and see whether it’s worth pursuing for the core, or as a plugin.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB