Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-06-23 12:42:12

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,437
Website GitHub

smd_pagicle: automatic (jQuery) pagination of articles

As it says on the tin, this one simply takes a loooooooong article and splits it into manageable chunks that your visitors can page between.

Where the awesome soo_multidoc allows you to manage a bunch of TXP articles as if they were part of one seamless tutorial, this plugin simply treats a regular article as a self-contained unit and chops it up at points you specify. Those points could either be some text delimiter of your choice, or at particular HTML tags (it defaults to splitting on every <h2>).

After that, the other plugin attributes are just fluff to make it all look prettier, with customisable animations and scrolling, header and footer support, yahde yahde.

Have a play with v0.2 and flip your way to pageville. As always, any enhancements, bugs or general comments… you know where I live in the virtual world.

Revision history
————————

All available versions and changes are listed here. Each entry indexes the relevant post(s) in the thread to learn about the features.

  • 23 Jun 09 | 0.1 | Initial release
  • 24 Jun 09 | 0.2 | Refactored code and removed most of the wrap attributes ; fixed validation issues and visibility of pager in non-paged articles, added ‘all’ and allowed MLP snippet replacement (all thanks ultramega)

Last edited by Bloke (2009-06-25 09:31:43)


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

#2 2009-06-23 20:03:19

saccade
Plugin Author
From: Neubeuern, Germany
Registered: 2004-11-05
Posts: 521

Re: smd_pagicle: automatic (jQuery) pagination of articles

“Nicht zu fassen!” (sorry for the german, but it is just unbelievable what you have in your storeroom, letting out some very fine stuff much faster I can learn using them).
And just the right things I thought about “It would be good if there was …”

Now I will train to think more things, that would be good to have :)

Thanks!

Offline

#3 2009-06-23 20:32:13

candyman
Member
From: Italy
Registered: 2006-08-08
Posts: 684

Re: smd_pagicle: automatic (jQuery) pagination of articles

Fantastic job.

Offline

#4 2009-06-24 08:09:17

ultramega
Member
Registered: 2006-02-26
Posts: 221

Re: smd_pagicle: automatic (jQuery) pagination of articles

You should definately use an addition with your name; Stef “Always in right time”!

Very cool thing!

Couple of questions:

1) previously clean page doesn’t validate after adding this: html-validator throws about 30 errors, mainly seems complaining about character entities, greater thans, lesser thans, ampersands.

2) Can a comment like <!—pageFlip—> safely be used in articles, so that it is unvisible in all situations…?

3) How to disable this with short articles without using different article form? Now it shows page 1 there with controls back & forth even there is no page turn commands in the article.

edit. Feature ideas:

1) add “disable-button” for viewers of the site
2) (MLP) editable navigation control texts

Last edited by ultramega (2009-06-24 08:19:24)

Offline

#5 2009-06-24 08:34:00

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

Re: smd_pagicle: automatic (jQuery) pagination of articles

Can see this coming in handy. Soon I’ll need an own smd_ tab for all your plugins I use :-)

oh, and +1 for ultramega’s first three suggestions (e.g. would be good for a full-length print version).


TXP Builders – finely-crafted code, design and txp

Offline

#6 2009-06-24 10:57:07

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: smd_pagicle: automatic (jQuery) pagination of articles

Wonderful pluginous Sfef :)

Some mayish improvement ideasish based on 1 minute look to the code:

  • Chunk the “pages” to it own UTF-8 encoded (text/xml) files (read: dynamic page) that are then called via Ajax (users without js support still see the non-js longish content). Instead of hiding we could actually manage the transfers. Also avoids too long direct js inserts and also makes the output 100% valid in all situations. Other way is to encode the insert and decode it on the insert event. (not needed really).
  • …Or/and could build an external JS file instead of placing the code directly to page template, or atleast surround the JS code with our beloved <!---, so non script supporting browsers won’t output the code.
  • You could use TXP’s wraptag functions for the container elements (makes the closing automatic).

P.S. Once again you made me laugh when I visited your site (hint. one of your random photos). It makes the downloading fun and improves the changes that the one will use it. Even kids, dogs and monkeys could enjoy it. Nerdy stuff made awesome.

ultramega wrote:

How to disable this with short articles without using different article form? Now it shows page 1 there with controls back & forth even there is no page turn commands in the article.

Custom fields for example.

Last edited by Gocom (2009-06-24 11:06:29)

Offline

#7 2009-06-24 12:38:33

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,437
Website GitHub

Re: smd_pagicle: automatic (jQuery) pagination of articles

ultramega

1) D’oh — should have wrapped the JS in CDATA and/or <!-- --> — or use Gocom’s suggestion. Will fix.
2) Yes, it works now BUT remember to add two spaces or notextile. in front of the text or the -- will be changed to a single —
3) Will fix so it only shows the output on pages that actualy have at least one split in them, thanks for spotting that
4) Just after I published the plugin yesterday I thought a “show all/show paged” would be handy. Will see if I can add that and make it remember your setting via a cookie
5) I’ve got some work to do on this front anyway because the arrows are all fixed chars. The only downside to making it MLP compatible (because I hate duplicating code) will be that the plugin requires smd_lib. Can everyone live with that, or would it be better if you could simply specify MLP ##snippets## as replacements for the arrows?

Gocom

Thanks for the tips. I’m, not quite sure what you mean about chunking the page. You mean keep the existing document intact (so non js users see it) and add the ‘paged’ version encoded afterwards in the page inside a hidden <div>? So if the encoded block exists/js is enabled, switch to the paged view and if not, then the existing article is displayed by default? Or do you mean write a physical file out that can then be managed by AJAX, loading it into the document? If you don’t mean that at all, could you please elaborate a little bit because my brain’s a tad slow today, thanks.

Oh, and I did think about TXP’s wraptag and to be honest I can’t remember why I didn’t use it. I think it’s because splitwraptag can be used in tandem with the splitat attribute and I couldn’t get the built in function to work quite how I wanted. But this plugin was lying on my hard drive for nearly a year: I found it the other day, tidied it up and just released it. Perhaps I should have actually looked at the code in detail to see if there were better ways of doing things with all the stuff I know now. I’ll have a proper look at it in the next few days and see if I can improve it. Thanks for keeping me sharp, man!

Last edited by Bloke (2009-06-24 20:29:59)


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

#8 2009-06-24 14:39:31

ultramega
Member
Registered: 2006-02-26
Posts: 221

Re: smd_pagicle: automatic (jQuery) pagination of articles

I tested using html comment as a splitter, it seems not to require any notextile-marking before it. Nice.

I think ##snippet## would be just fine for MLP.

Gocom, of course! With custom field this could be triggered only when needed, thanks for pointing. But if Bloke fixes this anyway, I can wait… Could you add an “Output SMD Page Splitter!” button to your textile bar? :)

Offline

#9 2009-06-25 09:27:18

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,437
Website GitHub

Re: smd_pagicle: automatic (jQuery) pagination of articles

v0.2 is out. The features, 90% of which are in response to ultramega’s findings:

  • A completely refactored codebase with no more wrapping of output required: corresponding attributes all removed
  • Surrounded javascript block with CDATA comment to prevent XHTML validator complaining. No idea what happens under HTML doctypes (anyone?)
  • Fixed paging so if there’s only one page the nav is not displayed
  • Added an ‘all’ nav option which will turn off paging in that document. Not figured out a way to make this persistent yet: if it’s an issue for people, I can look into it
  • Added navtext attribute which should be capable of taking MLP snippets. Not tested it so any field trials welcome: please report

Thanks ultramega for giving the plugin a good grilling and suggesting the fixes/mods. Anything else, you all know where I am.

Last edited by Bloke (2009-06-25 09:37:06)


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

#10 2009-06-25 11:04:19

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: smd_pagicle: automatic (jQuery) pagination of articles

Bloke wrote:

No idea what happens under HTML doctypes (anyone?)

I say, don’t care Bloke :) Textpattern’s core tags output only XHTML anyway. Requires some playing around if someone even wanted to use HTML instead XHTML.

Offline

#11 2009-06-25 16:11:44

kostas45
Member
From: Greece
Registered: 2007-11-08
Posts: 61

Re: smd_pagicle: automatic (jQuery) pagination of articles

Is there a way I can disable the animation effect?
I.e. how can I not use jQuery’s animate() function at all?

Cheers,
Kostas

Offline

#12 2009-06-25 18:46:00

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: smd_pagicle: automatic (jQuery) pagination of articles

Could someone share his live example of this plugin? :) Would be awesome, I think…


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

Board footer

Powered by FluxBB