Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#76 2014-10-30 22:55:22

MrLongbaugh
Member
From: Hamburg - Germany
Registered: 2004-10-11
Posts: 116

Re: etc_pagination: paginate everything

Hey there,

for a section news I would like to show a list of news in a colum. As there a quite some news they should be shown up as 10 per page with a link forth and back.

I used the plugin etc_pagination

For this the article_custom tag is used

<txp:article_custom form="article_listing" offset="0" pgonly="1" status="4" section="News" limit="5" offset='<txp:etc_offset pgcounter="page" pageby="5" />' />

If it is in article mode everything works great. But if an article link is clicked an it is in individual_article mode the pagination is no longer shown.

Is there another way to show the article list in either mode?

Thanks for any idea.

Last edited by MrLongbaugh (2014-11-04 19:54:31)

Offline

#77 2014-10-31 20:17:18

etc
Developer
Registered: 2010-11-11
Posts: 5,677
Website GitHub

Re: etc_pagination: paginate everything

Hello,

to function properly, etc_pagination needs two parameters:

  • the number of pages. This is set by <txp:article /> (not custom), but not for individual article views;
  • the current page. This is typically given by pg URL parameter, but you seem to use page (which is ok). Again, individual articles URL do not contain it.

You can, however, create them manually. Try putting this in your column

<txp:if_individual_article>
<txp:etc_pagination pgcounter="page" pages='<txp:etc_numpages section="news" />' />
<txp:else />
... the prev/next stuff that currently works ...
</txp:if_individual_article>

This should produce a pagination bar in the individual article mode too, but we still have no information on the current page number. To add it, you could append something like ?page=<txp:etc_offset pgcounter="page" type="page" /> to the articles url in article_listing form.

Don’t hesitate if you need further assistance.

Offline

#78 2014-11-04 19:48:01

MrLongbaugh
Member
From: Hamburg - Germany
Registered: 2004-10-11
Posts: 116

Re: etc_pagination: paginate everything

Thanks etc,

thanks a lot. That worked perfectly.

Just for the record:

<txp:if_individual_article>
  <txp:article_custom form="article_listing" offset="0" pgonly="1"  status="4" 
    section="news" limit="10"  offset='<txp:etc_offset pgcounter="page" pageby="10" />' />
<txp:else />
  <txp:article_custom form="article_listing" offset="0" pgonly="1"  status="4" 
    section="news" limit="10"  offset='<txp:etc_offset pgcounter="page" pageby="10" />' />
</txp:if_individual_article>
<div id="pagi">
  <txp:etc_pagination pages='<txp:variable name="numPages" />' pgcounter="page"
	 prev="&#171; vor" next="weiter &#187;" break=" | " /></div>
</div>

And the link in the form:

<a href="<txp:permlink />?page=<txp:etc_offset pgcounter="page" type="page" />">
  <txp:title />
</a>

Last edited by MrLongbaugh (2014-11-04 19:50:22)

Offline

#79 2015-03-20 11:47:51

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,565
Website GitHub Mastodon

Re: etc_pagination: paginate everything

Hi Oleg,

Great plugin!

Is there a way I can get close to the following markup?

<nav class="layout--span-1-8 paginator" aria-label="Blog navigation">
    <a class="prev" rel="prev" href="#" title="Go to previous page" aria-label="Go to previous page">Prev</a>
    <a class="next" rel="next" href="#" title="Go to next page" aria-label="Go to next page">Next</a>
    <ul class="pagination">
        <li>
            <a rel="prev" href="#" title="Go to page 1" aria-label="Go to page 1">1</a>
        </li>
        <li>
            <span data-rel="self">2</span>
        </li>
        <li>
            <a rel="next" href="#" title="Go to page 3" aria-label="Go to page 3">3</a>
        </li>
        <li>
            <a href="#" title="Go to page 4" aria-label="Go to page 4">4</a>
        </li>
        <li>
            <a href="#" title="Go to page 5" aria-label="Go to page 5">5</a>
        </li>
        <li>
            <a href="#" title="Go to page 6" aria-label="Go to page 6">6</a>
        </li>
        <li>
            <a href="#" title="Go to page 7" aria-label="Go to page 7">7</a>
        </li>
        <li>
            <a href="#" title="Go to page 8" aria-label="Go to page 8">8</a>
        </li>
        <li>
            <a href="#" title="Go to page 9" aria-label="Go to page 9">9</a>
        </li>
        <li>
            <a href="#" title="More pages" aria-label="More pages">&hellip;</a>
        </li>
    </ul>
</nav>

The <nav> tag I can generate myself outs of the tag, so that and it’s attributes don’t need to be considered.

By the way, rel=first and rel=last are not valid in HTML5, so I would want those to appear in any code.

Also, it’d be great if this plugin was available on GitHub – I could certainly help with some of the documentation if it were.

Offline

#80 2015-03-20 12:26:25

etc
Developer
Registered: 2010-11-11
Posts: 5,677
Website GitHub

Re: etc_pagination: paginate everything

Hi Phil, thank you. This should be close to what you want:

<txp:etc_pagination wraptag="ul" class="layout--span-1-8 paginator" atts=' aria-label="Blog navigation"'
	prev='<a class="prev" rel="prev" href="{href}" title="Go to previous page" aria-label="Go to previous page">Prev</a>'
	next='<a class="next" rel="next" href="{href}" title="Go to next page" aria-label="Go to next page">Next</a>'
	link='<li><a href="{href}" title="Go to page {*}" aria-label="Go to page {*}">{*}</a></li>,<li><span data-rel="self">{*}</span></li>'
	mask='{prev}{next}
	<ul class="pagination">
		{links}
		<li><a href="#" title="More pages" aria-label="More pages">&hellip;</a></li>
	</ul>' 
/>

You can add rel="{rel}" attribute to <a /> in link, but they will produce these invalid (sorry and thanks) last/first as well as empty values. Tell me if you need it, it’s been a long time I haven’t touched etc_pagination. And thank you for the help proposal — gladly accepted — it remains me to read GitHub howtos. :)

Last edited by etc (2015-03-20 12:28:34)

Offline

#81 2015-03-20 14:25:30

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,565
Website GitHub Mastodon

Re: etc_pagination: paginate everything

Hi Oleg,

I’m so close, yet still got a couple of issues! I’m actually using this code so far:

<txp:variable name="more" value='<txp:newer /><txp:older />' />
<txp:variable name="prev" value='<txp:newer />' />
<txp:variable name="next" value='<txp:older />' />
<txp:if_variable name="more" value="">
<txp:else />
    <div class="wrapper-inner <txp:variable name="wrapper-inner" />">
        <div class="container">
            <nav class="layout--span-1-8 paginator" aria-label="Blog navigation">
                <txp:if_variable name="prev" value="">
                    <span class="prev disabled" aria-label="This is the first page">Prev</span>
                <txp:else />
                    <a class="prev" rel="prev" href="<txp:newer />" title="Go to previous page" aria-label="Go to previous page">Prev</a>
                </txp:if_variable>
                <txp:if_variable name="next" value="">
                    <span class="next disabled" aria-label="This is the last page">Next</span>
                <txp:else />
                    <a class="next" rel="next" href="<txp:older />" title="Go to next page" aria-label="Go to next page">Next</a>
                </txp:if_variable>
                <txp:etc_pagination wraptag="ul" class="pagination" range="4"
                    link='<li><a href="{href}" title="Go to page {*}" aria-label="Go to page {*}">{*}</a></li>,<li class="current"><b title="Current page" aria-label="Current page">{*}</b></li>'
                    gap='<li><span title="More pages" aria-label="More pages">…</span></li>'
                    mask="{links}"/>
            </nav>
        </div>
    </div>
</txp:if_variable>

But the gap symbol (…) is not being rendered at all, or the last page number and/or first page number.

So I’ve got this so far:

<nav class="layout--span-1-8 paginator" aria-label="Blog navigation">
    <a class="prev" rel="prev" href="#" title="Go to previous page" aria-label="Go to previous page">Prev</a>
    <a class="next" rel="next" href="#" title="Go to next page" aria-label="Go to next page">Next</a>
    <ul class="pagination">
        <li><a href="#" title="Go to page 3" aria-label="Go to page 3">3</a></li>
        <li><a href="#" title="Go to page 4" aria-label="Go to page 4">4</a></li>
        <li class="current"><b title="Current page" aria-label="Current page">5</b></li>
        <li><a href="#" title="Go to page 6" aria-label="Go to page 6">6</a></li>
        <li><a href="#" title="Go to page 7" aria-label="Go to page 7">7</a></li>
    </ul>
</nav>

When I need to get to this:

<nav class="layout--span-1-8 paginator" aria-label="Blog navigation">
    <a class="prev" rel="prev" href="#" title="Go to previous page" aria-label="Go to previous page">Prev</a>
    <a class="next" rel="next" href="#" title="Go to next page" aria-label="Go to next page">Next</a>
    <ul class="pagination">
        <li><a href="#" title="Go to page 1" aria-label="Go to page 1">1</a></li>
        <li><span title="More pages" aria-label="More pages">&hellip;</span></li>
        <li><a href="#" title="Go to page 3" aria-label="Go to page 4">4</a></li>
        <li class="current"><b title="Current page" aria-label="Current page">5</b></li>
        <li><a href="#" title="Go to page 5" aria-label="Go to page 6">6</a></li>
        <li><span title="More pages" aria-label="More pages">&hellip;</span></li>
        <li><a href="#" title="Go to page 11" aria-label="Go to page 11">11</a></li>
    </ul>
</nav>

Offline

#82 2015-03-20 18:15:50

etc
Developer
Registered: 2010-11-11
Posts: 5,677
Website GitHub

Re: etc_pagination: paginate everything

Almost there, I think, just replace mask value with {first}{<+}{links}{+>}{last}.

Offline

#83 2015-03-20 20:47:08

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,565
Website GitHub Mastodon

Re: etc_pagination: paginate everything

That’s absolute perfect Oleg, exactly what I needed! Thanks again for the great plugin.

If/when you get to grips with github, I’ll happy to help write out some deeper documentation for this plugin.

Offline

#84 2015-03-20 22:40:26

etc
Developer
Registered: 2010-11-11
Posts: 5,677
Website GitHub

Re: etc_pagination: paginate everything

Thank you for the feedback, Phil, nice to hear it. I have created a github repository and added you as contributor (don’t know if it works), please feel free to contribute in any way.

I have removed the depreciated rel values from the next version, but note that you can alter the output of any plugin with etc_query:

<txp:etc_query data='<txp:etc_pagination ... />'
	replace="//a[@rel='' or @rel='first' or @rel='last']@@rel" />

will remove the offending rel attribute from <a />s.

Offline

#85 2015-03-21 07:46:38

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,565
Website GitHub Mastodon

Re: etc_pagination: paginate everything

Hi again Oleg,

Thanks for the GitHub access. I’d suggest uploading the plugin code and working on the README.textile file rather than on a Wiki page, similar to how we have done with zem_contact_reborn on GitHub.

GitHub supports Textile format so you can use the same documentation for the readme and within the plugin itself, which saves extra effort.

Offline

#86 2015-03-21 13:05:29

etc
Developer
Registered: 2010-11-11
Posts: 5,677
Website GitHub

Re: etc_pagination: paginate everything

Thank you for your help, Phil! I need some time to get used to GitHub, but will upload the latest code after some testing. Unfortunately, the help file (inherited from ob1_pagination plugin) was HTML formatted from the start.

Side-note: are we slowly migrating from .org to GitHub?

Offline

#87 2015-03-21 14:10:17

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,565
Website GitHub Mastodon

Re: etc_pagination: paginate everything

I’ve Textiled your help file and made a few alterations. It would be good to flesh this out with a few more examples (lifted from this forum thread) in due course.

I’ll leave it to you for now – happy GitHubbing!

Offline

#88 2015-03-22 11:39:14

etc
Developer
Registered: 2010-11-11
Posts: 5,677
Website GitHub

Re: etc_pagination: paginate everything

That’s really kind of you, Phil, many thanks! I have uploaded the plugin php code, it includes now your help version that I will continue to complete. Is there any mean to keep it synced with the README file?

Offline

#89 2015-03-22 13:07:39

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,565
Website GitHub Mastodon

Re: etc_pagination: paginate everything

Hi Oleg,

You would have to cut and paste any changes you make to the readme into the plugin help section (and vice versa) to keep them in sync – at least that’s what I do.

Offline

#90 2015-03-22 21:53:21

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

Re: etc_pagination: paginate everything

philwareham wrote #289273:

You would have to cut and paste any changes you make to the readme into the plugin help section (and vice versa) to keep them in sync – at least that’s what I do.

Or just compile the plugin package from the readme instead of having some (shitty, may I add) singular PHP file zrc_template (or what the fuck it’s called) uses.

Would be great if the repository was Composer (the package manager, not that web GUI compiler) compatible too.

Offline

Board footer

Powered by FluxBB