Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#49 2020-10-16 14:22:01

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

Re: Complex Pagination using Newer/Older with Shift

philwareham wrote #326437:

this syntax is a little easier to read and understand.

More importantly, you don’t have to modify it (unlike with evaluate) when adding/deleting tags.

phiw13 wrote #326438:

If I understand it right, <txp:tag[1] /> is processed first, then <txp:tag[2] />, and last un-“labeled” (counted) tag <txp:tag /> ? I think that syntax is OK.

Absolutely, glad you find it useful.

Offline

#50 2020-10-16 14:38:47

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

Re: Complex Pagination using Newer/Older with Shift

Wow. Fab idea, Oleg.

Does it only work inside container tags, or can it be used generally to, for example, run something on the 2nd pass without wrapping it in <txp:hide process="2">? (not suggesting we do that, it’s a genuine question for documentation purposes!)


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

#51 2020-10-16 14:41:58

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

Re: Complex Pagination using Newer/Older with Shift

Bloke wrote #326440:

Wow. Fab idea, Oleg.

Thanks!

Does it only work inside container tags, or can it be used generally to, for example, run something on the 2nd pass without wrapping it in <txp:hide process="2">?

It should work, though it runs on the first pass. Edit: note that this order is applicable to siblings only, so this can not totally imitate the second pass.

Offline

#52 2020-10-16 19:00:04

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

Re: Complex Pagination using Newer/Older with Shift

Is the ascending order of execution (i.e. 1, 2, …) okay, or we’d better switch to the descending one? The latter could allow for ‘post-normal’ processing too: …, 2, 1, 0 (or orderless tags), -1, -2, …

Offline

#53 2020-10-17 00:18:40

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,162
Website

Re: Complex Pagination using Newer/Older with Shift

etc wrote #326442:

Is the ascending order of execution (i.e. 1, 2, …) okay, or we’d better switch to the descending one? The latter could allow for ‘post-normal’ processing too: …, 2, 1, 0 (or orderless tags), -1, -2, …

Current ordering seems fine to me, easy to read/grasp for less math-wired brains (!).


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#54 2020-10-17 08:26:53

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

Re: Complex Pagination using Newer/Older with Shift

phiw13 wrote #326446:

Current ordering seems fine to me, easy to read/grasp for less math-wired brains (!).

Let it be, then. I will try to find another meaning for negative order values.

Offline

#55 2021-09-05 00:36:24

kuro
Member
From: Mexico City | Mérida, Yucatán
Registered: 2005-08-26
Posts: 73
Website

Re: Complex Pagination using Newer/Older with Shift

@philwareham

Hello!

i’m using this code for archive page (with your txp boostrap theme)


<!DOCTYPE html>
<html lang="<txp:lang />" dir="<txp:text item="lang_dir" />">
<head>
    <txp:output_form form="head" />
    <title><txp:page_title /></title>
    <txp:if_article_list>
        <meta name="description" content="">
        <txp:variable name="page" value='<txp:page_url type="pg" />' />
        <txp:variable name="prev" value='<txp:newer />' />
        <txp:variable name="next" value='<txp:older />' />
        <txp:if_variable name="page" value="">
            <meta name="robots" content="index, follow, noodp, noydir">
            <link rel="canonical" href="<txp:section url="1" />">
        <txp:else />
            <meta name="robots" content="noindex, follow, noodp, noydir">
            <link rel="canonical" href="<txp:section url="1" />?pg=<txp:page_url type="pg" />">
        </txp:if_variable>
        <txp:if_variable name="prev" value="">
        <txp:else />
            <link rel="prev" href="<txp:variable name="prev" />"
        </txp:if_variable>
        <txp:if_variable name="next" value="">
        <txp:else />
            <link rel="next" href="<txp:variable name="next" />"
        </txp:if_variable>
    <txp:else />
        <txp:meta_author title="1" />
        <meta name="robots" content="index, follow, noodp, noydir">
        <link rel="canonical" href="<txp:permlink />">
    </txp:if_article_list>
</head>
<txp:if_search>
    <body class="with-jumbotron" itemscope itemtype="https://schema.org/SearchResultsPage">
<txp:else />
    <txp:if_article_list>
        <body class="with-jumbotron" itemscope itemtype="https://schema.org/CollectionPage">
    <txp:else />
        <body class="with-jumbotron" itemscope itemtype="https://schema.org/WebPage">
    </txp:if_article_list>
</txp:if_search>
    <txp:output_form form="body_header" />
    <txp:output_form form="jumbotron" />
    <div class="wrapper">
        <div class="container">
            <!-- Main content -->
            <main id="main" aria-label="<txp:text item="main_content" />" itemscope itemtype="https://schema.org/Blog">
                   <!-- is this the search result page? also omits the pagination links below (uses pagination format within search_display.txp instead) -->
                <txp:if_search>
                    <txp:output_form form="search_display" />
                 <txp:else />
                    <txp:if_article_list>
                        <h1 itemprop="name"><txp:section title /></h1>
                        <txp:article class="article-list" form="article_listing" limit="10" wraptag="ul" status="4" />
                        <txp:article_custom class="article-list" excerpted="1" form="article_listing" frontpage="1" limit="7" sort="Posted desc" status="4" wraptag="ul" />
                    <txp:else />
                     <txp:article class="article-list" form="article_listing" limit="10" wraptag="ul" status="4" />
                       <!-- add pagination links to foot of front page/author listings/category listings if there are more articles available -->
                    <txp:if_plugin name="etc_pagination" version="0.5">
                        <txp:evaluate>
                             <nav aria-label="<txp:text item="page_nav" />">
                                 <txp:etc_pagination range="3"
                                    prev='<li class="page-item"><a class="page-link" rel="prev" href="{href}"><span aria-hidden="true">&laquo;</span><span class="sr-only"><txp:text item="prev" /></span></a></li>'
                                     next='<li class="page-item"><a class="page-link" rel="next" href="{href}"><span aria-hidden="true">&raquo;</span><span class="sr-only"><txp:text item="next" /></span></a></li>'
                                    link='<li class="page-item"><a class="page-link" href="{href}">{*}</a></li>,<li class="page-item active"><span class="page-link">{*} <span class="sr-only">(<txp:text item="current" />)</span></span></li>'
                                    gap='<li class="page-item"><span role="separator">…<span class="sr-only"><txp:text item="more_pages" /></span></span></li>'
                                    mask='<ul class="pagination">{prev}{first}{<+}{links}{+>}{last}{next}</ul>' />
                             </nav>
                         </txp:evaluate>
                     <txp:else />
                         <txp:evaluate test="next,prev">
                            <nav aria-label="<txp:text item="page_nav" />">
                                <txp:older class="btn btn-outline-primary" rel="next">
                                 <txp:text item="older" />
                                 </txp:older>
                                 <txp:newer class="btn btn-outline-primary" rel="prev">
                                <txp:text item="newer" />
                                 </txp:newer>
                            </nav>
                        </txp:evaluate>
                     </txp:if_plugin>
                    </txp:if_article_list>
                </txp:if_search>
            </main>
        </div> <!-- /.container -->
    </div> <!-- /.wrapper -->
    <txp:output_form form="lastfm" />
    <txp:output_form form="body_footer" />
</body>
</html>

But the pagination doesn’t appears :/

i tried:

Change the attribute (txp_output-form) with article_listing, archive_list
and nothing happens.

Where is my error?

Have a great weekend!

Offline

#56 2021-09-05 08:35:03

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

Re: Complex Pagination using Newer/Older with Shift

Hi,

I would start by checking this block:

                         <txp:evaluate test="next,prev">
                            <nav aria-label="<txp:text item="page_nav" />">
                                <txp:older class="btn btn-outline-primary" rel="next">
                                 <txp:text item="older" />
                                 </txp:older>
                                 <txp:newer class="btn btn-outline-primary" rel="prev">
                                <txp:text item="newer" />
                                 </txp:newer>
                            </nav>
                        </txp:evaluate>

<txp:evaluate test="next,prev" /> is asked to test <txp:next /> and <txp:prev /> tags, but there is none. Try to replace it with test="newer, older"?

Also note that <txp:evaluate /> is useless in

                        <txp:evaluate>
                             <nav aria-label="<txp:text item="page_nav" />">
                                 <txp:etc_pagination range="3"
                                    prev='<li class="page-item"><a class="page-link" rel="prev" href="{href}"><span aria-hidden="true">&laquo;</span><span class="sr-only"><txp:text item="prev" /></span></a></li>'
                                     next='<li class="page-item"><a class="page-link" rel="next" href="{href}"><span aria-hidden="true">&raquo;</span><span class="sr-only"><txp:text item="next" /></span></a></li>'
                                    link='<li class="page-item"><a class="page-link" href="{href}">{*}</a></li>,<li class="page-item active"><span class="page-link">{*} <span class="sr-only">(<txp:text item="current" />)</span></span></li>'
                                    gap='<li class="page-item"><span role="separator">…<span class="sr-only"><txp:text item="more_pages" /></span></span></li>'
                                    mask='<ul class="pagination">{prev}{first}{<+}{links}{+>}{last}{next}</ul>' />
                             </nav>
                         </txp:evaluate>

since <txp:text item="page_nav" /> will always return something, so the block is never considered empty. You should pass it test="etc_pagination" attribute.

Hope that helps.

Offline

#57 2021-09-23 11:19:51

kuro
Member
From: Mexico City | Mérida, Yucatán
Registered: 2005-08-26
Posts: 73
Website

Re: Complex Pagination using Newer/Older with Shift

etc wrote #331530:

Hi,

I would start by checking this block:

<txp:evaluate test="next,prev">...

<txp:evaluate test="next,prev" /> is asked to test <txp:next /> and <txp:prev /> tags, but there is none. Try to replace it with test="newer, older"?

Also note that <txp:evaluate /> is useless in

<txp:evaluate>...

since <txp:text item="page_nav" /> will always return something, so the block is never considered empty.

You should pass it @test=“etc_pagination”@ attribute.
And this goes on?

Thanks

Offline

#58 2021-09-23 11:43:38

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

Re: Complex Pagination using Newer/Older with Shift

In reply to kuro #331651:

You should pass it test=“etc_pagination” attribute.
And this goes on?

Yes, for the second block this should do.

Offline

#59 2021-09-23 11:51:21

kuro
Member
From: Mexico City | Mérida, Yucatán
Registered: 2005-08-26
Posts: 73
Website

Re: Complex Pagination using Newer/Older with Shift

<txp:evaluate test="newer, older">
                            <nav aria-label="<txp:text item="page_nav" />">
                                <txp:older class="btn btn-outline-primary" rel="next">
                                 <txp:text item="older" />
                                 </txp:older>
                                 <txp:newer class="btn btn-outline-primary" rel="prev">
                                <txp:text item="newer" />
                                 </txp:newer>
                            </nav>
                        </txp:evaluate>
<txp:evaluate *test=“etc_pagination”*>
                             <nav aria-label="<txp:text item="page_nav" />">
                                 <txp:etc_pagination range="3"
                                    prev='<li class="page-item"><a class="page-link" rel="prev" href="{href}"><span aria-hidden="true">&laquo;</span><span class="sr-only"><txp:text item="prev" /></span></a></li>'
                                     next='<li class="page-item"><a class="page-link" rel="next" href="{href}"><span aria-hidden="true">&raquo;</span><span class="sr-only"><txp:text item="next" /></span></a></li>'
                                    link='<li class="page-item"><a class="page-link" href="{href}">{*}</a></li>,<li class="page-item active"><span class="page-link">{*} <span class="sr-only">(<txp:text item="current" />)</span></span></li>'
                                    gap='<li class="page-item"><span role="separator">…<span class="sr-only"><txp:text item="more_pages" /></span></span></li>'
                                    mask='<ul class="pagination">{prev}{first}{<+}{links}{+>}{last}{next}</ul>' />
                             </nav>
                         </txp:evaluate>

Offline

Board footer

Powered by FluxBB