Forum

Thread tagged as: Question, Addons, Blog

Pagination and "start" option in perch_blog_custom array

Is there a particular reason why page pagination doesn't work when I have a "start" option in my array? When I remove it from the array, pagination works fine.

Also, when I paginate comments, the code outputs the links to each individual page in addition to the "previous" and "next" links, but when I use the same code for blog posts, I only get the "previous" and "next" links. How do I display individual page links in the pagination for blog listings?

Paul Moignard

Paul Moignard 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, setting start disables the pagination, as the pagination otherwise controls the result set cursor.

For the other issue, post your template and we'll take a look.

Thanks for clarifying that Drew!

Here's my template for comments:

<perch:before>
    <ul class="comments listing">
</perch:before>
        <li id="comment<perch:blog id="commentID" type="hidden" />">
            <div class="comment">
                <div class="commenter">
                    <perch:if exists="commentURL"><a href="<perch:blog id="commentURL" type="url" label="URL" order="3" />"></perch:if>
                        <h4 class="poster"><perch:blog id="commentName" type="text" label="Name" order="1" required="true" /> - <perch:blog id="commentDateTime" format="%d %b %Y %X" type="date" time="true" label="Date" /></h4>
                    <perch:if exists="commentURL"></a></perch:if>
                </div>
                <perch:blog id="commentHTML" encode="false" html="true" type="textarea" label="Message (HTML)" order="4" required="true" />
            </div>
        </li>
<perch:after>
    </ul>
                         <perch:if exists="paging">
                            <div id="browse-nav" class="cf paging fadehover">
                                <perch:if exists="not_first_page">
                                    <a href="<perch:blog id="prev_url" type="hidden" encode="false" />" id="prev" class="left">Previous Post</a>
                                </perch:if>
                                    <!-- span class="left">Page <perch:blog id="current_page" type="hidden" /> of <perch:blog id="number_of_pages" type="hidden" /></span> -->
                                    <perch:blog id="page_links" encode="false" />
                                <perch:if exists="not_last_page">
                                    <a href="<perch:blog id="next_url" type="hidden" encode="false" />" id="next" class="right">Next Post</a>
                                </perch:if>
                              </div><!-- End browse-nav -->
                        </perch:if>
</perch:after>

And here is my template for the blog post list:

<perch:before>
<ul class="hfeed listing">
</perch:before>
    <li class="blog-lst-sml blog-entry">
        <h1><a href="<perch:blog id="postURL" />" rel="bookmark" class="entry-title"><perch:blog id="postTitle" /></a></h1>
        <span class="date"><perch:blog order="2" id="postDateTime" format="%B %d, %Y" /></span>
        <div class="cf">
            <div class="cf">
            <div class="blog-lst-sml-img left">
                <img src="<perch:blog id="image" type="image" width="100" height="100" crop="true" />" alt="<perch:blog id="postTitle" />" />
            </div><!-- End blog-lst-sml-img -->
            <div class="blog-lst-sml-text right">
                <perch:blog id="postDescHTML" type="textarea" textile="true" words="50" append="..." /><a class="read-more right" href="<perch:blog id="postURL" />" rel="bookmark">Read More</a>
            </div><!-- End blog-lst-sml-text -->
            </div>
            <div class="blog-footer cf">
                <a class="comments left" href="<perch:blog id="postURL" />#comments">Comments (<perch:blog id="postCommentCount"/>)</a>
                <div class="share cf">
                    <span class="left">Share</span>
                    <ul class="social-links right fadehover">
                        <li id="pinterest" class="popuplink"><a href="javascript:void(0);">Pinterest</a></li>
                        <li id="facebook"><a href="https://www.facebook.com/sharer.php?u=https://www.designsbystarling.com/blog/<perch:blog id="postURL" />" target="_blank">Facebook</a></li>
                        <li id="twitter"><a href="https://twitter.com/share?url=https://www.designsbystarling.com/blog/<perch:blog id="postURL" />">
Share This on Twitter">Twitter</a></li>
                    </ul><!-- End social-links -->          
                </div><!-- End share -->                
            </div><!-- End blog-footer -->
        </div>
    </li>
<perch:after>
    </ul>
                         <perch:if exists="paging">
                            <div id="browse-nav" class="cf paging fadehover">
                                <perch:if exists="not_first_page">
                                    <a href="<perch:blog id="prev_url" type="hidden" encode="false" />" id="prev" class="left">Previous Post</a>
                                </perch:if>
                                    <span class="left">Page <perch:blog id="current_page" type="hidden" /> of <perch:blog id="number_of_pages" type="hidden" /></span>
                                    <perch:blog id="page_links" encode="false" />
                                <perch:if exists="not_last_page">
                                    <a href="<perch:blog id="next_url" type="hidden" encode="false" />" id="next" class="right">Next Post</a>
                                </perch:if>
                              </div><!-- End browse-nav -->
                        </perch:if>
</perch:after>
Drew McLellan

Drew McLellan 2638 points
Perch Support

You have page-links included in the template. I'm presuming you've enabled them on the page function, yes?

No, I didn't. They just show up for comments without having to enable them on the page function, so I didn't know it was necessary to enable them on perch_blog_custom. Its working fine now. Thanks Drew!