Forum

Thread tagged as: Question

Thanks Hussein. But the blog post has not pagination, other than the comments.

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

I'm aware of that. You just need to set the pagination-var. You're not actually enabling pagination for the blog post.

Give it a try!

Giving both pagination-var worked. You can see it from here: https://stage.bergmedia.co.uk/blog/post.php?s=2017-10-21-blog-test.

Thank you Sir. I can settle for this now.

            <?php
            perch_blog_custom([
        'filter' => 'postSlug',
        'match' => 'eq',
        'value' => perch_get('s'),
        'pagination-var' => 'anything',
        ]);
             ?>


                <?php
                    perch_blog_post_comments(perch_get('s'), [
                'template' => 'comment.html',
                'paginate' => true,
                'count' => 3,
                'sort-order' => 'DESC',
                    'pagination-var' => 'comm',
                ]);
                ?>

I have disabled the pagination as it re-loads the entire page, just to show the rest of the comments.

I used a load more function instead.

Ideally, A database query to load more comment is the best option.

Drew McLellan

Drew McLellan 2638 points
Perch Support

It doesn't have to reload the entire page - that's down to your frontend code.

I will give it another try. Just like Hussein said, pagination-var does not work on perch_blog_post_comments.

"It doesn't have to reload the entire page - that's down to your frontend code." Well how will you do it?

Post.php

            <?php
                    PerchSystem::set_var('page_tags.html',
                    perch_blog_post_tags(perch_get('s'), [], true));
                    perch_blog_custom([
                    'filter' => 'postSlug',
                    'match' => 'eq',
                    'paginate' => false,
                    'value' => perch_get('s'),
                    'pagination-var' => 'blogpage',
                    ]);
             ?>

             <?php
                    perch_blog_post_comments(perch_get('s'), [
                    'template' => 'comment.html',
                    'pagination-var' => 'comms',
                    'paginate' => true,
                    'count' => 3,
                    'sort-order' => 'DESC',
                    ]);
             ?>

comment.html

<perch:before>
<div class="row">
    <h2 class="fs-26">Comments and responses</h2>
    <div class="col-lg-12 pd-top-30">
</perch:before>
    <div class="col-lg-12 bor-top pd-top-20 <perch:blog id="perch_item_odd" type="hidden" />" id="comment<perch:blog id="commentID" type="hidden" />" >
<div class="col-lg-2">
    <img class="circle" src="//www.gravatar.com/avatar/<perch:blog id="commentEmail" type="email" label="Email" order="2" hash="md5" required="true" />?s=120&d=mm" width="75" height="75" />
    </div>

<div class="col-lg-10">

    <p rel="bookmark" class="comm-date"><perch:blog id="commentDateTime" format="%d %b %Y %X" type="date" time="true" label="Date" /></p>
    <perch:blog id="commentHTML" encode="false" html="true" type="textarea" label="Message (HTML)" order="4" />
</div>
</div>
<perch:after>
<perch:template path="pagination/comments.html" rescope="parent" />
</div></div>
</perch:after>

pagination/comments.html

<perch:if exists="paging">
  <div class="paging">
    Pagex <perch:blog id="current_page" type="hidden" /> of <perch:blog id="number_of_pages" type="hidden" />
    <perch:if exists="not_first_page">
      <a href="<perch:blog id="prev_url" type="hidden" encode="false" />">Previous</a>
    </perch:if>
    <perch:blog id="page_links" encode="false" type="hidden" />
    <perch:if exists="not_last_page">
      <a href="<perch:blog id="next_url" type="hidden" encode="false" />">Next</a>
    </perch:if>
  </div>
</perch:if>
Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Loading extra content without page reload is a front-end matter and can be handled with Javascript. It's not Perch-specific.