Comments pagination
How to get the comment pagination to work
Diagnossic Report
Summary information
Perch: 3.0.10, PHP: 5.4.45, MySQL: mysqlnd 5.0.10 - 20111026 - $Id: c85105d7c6f7d70d609bb4c000257868a40840ab $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (3.0.10), assets (3.0.10), categories (3.0.10), perch_blog (5.6.1), perch_forms (1.9.1), perch_members (1.6.1)
App runtimes: <?php $apps_list = ['perch_blog','perch_members','perch_forms' ];
PERCH_LOGINPATH: /bmcms
PERCH_PATH: /var/www/vhosts/mydomainpath/bmcms
PERCH_CORE: /var/www/vhosts/mydomainpath/subdomains/mydomainpath/core
PERCH_RESFILEPATH: /var/www/vhosts/mydomainpath/subdomains/mydomainpath/bmcms/resources
Image manipulation: GD Imagick
PHP limits: Max upload 16M, Max POST 128M, Memory: 128M, Total max file upload: 16M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
SCRIPT_NAME: /bmcms/core/settings/diagnostics/index.php
REQUEST_URI: /bmcms/core/settings/diagnostics/
DOCUMENT_ROOT: /var/www/vhosts/mydomainpath
HTTP_HOST: mydomain.co.uk
Post.php
<?php PerchSystem::set_var('page_tags.html',
perch_blog_post_tags(perch_get('s'), [], true));
perch_blog_post(perch_get('s')); ?>
<?php
perch_blog_post_comments(perch_get('s'), array(
'paginate' => true,
'count' => 2,
));
?>
<?php perch_blog_post_comment_form(perch_get('s')); ?>
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" id="comment<perch:blog id="commentID" type="hidden" />" >
<div class="col-lg-1">
<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-11">
<div class="commenter">
<perch:if exists="commentURL"><a href="<perch:blog id="commentURL" type="url" label="URL" order="3" />"></perch:if>
<strong><perch:blog id="commentName" type="text" label="Name" order="1" required="true" />:</strong>
<perch:if exists="commentURL"></a></perch:if>
</div>
<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>
</div></div>
</perch:after>
That looks fine - I think you just need to add the pagination tags to your template wherever you want them.
I have tried to add the pagination tags, but it did not work.
But, it was my mistake. I forgot to change <perch:content> to <perch:blog>
Thanks.
If in doubt,
<perch:showall />
will show you what's available, and what tag namespace you should be using.I just realized that is goes to the next page of comments, and losing the blog post content. Is there something to be changed in the pagination tag?
Yes, most likely. So you have some sort of post slug or ID on the URL? If so you'll want to include that in your links.
Can you tell me what ID or url are you referring to? All info in my template is above. I been searching thread for hour for similar issue, with no luck. Thanks in advance
How are you deciding which post to show on the page?
You need to make sure that whatever you're doing is carried through on the pagination URLs.
Hi Drew. This is a pagination to the blog comment,s. Imagine you have 50 comments in one single page. What I like to accomplish, is to have a blog comment pagination to click next and previous comments.
See the dev link below: stage.bergmedia dot co dot uk /blog/2017-10-21-blog-test
Thanks
Ok, so it looks like you have a blog slug. Is that slug on your pagination links?
Everything I have done so far is the one above. So can you guide me on how to achieve this?
I'm building my client network to change their CMS to Perch. I want to learn most of it before converting my clients to use your CMS.
Thanks in advance
When you click to go to page 2, is the post slug on the URL?
Post slug, you mean the blog title?
/blog/2017-10-21-blog-test
after clicking: /blog/post.php?s=2017-10-21-blog-test&page=2
But the blog post is not showing
Ok, that looks fine. I think you need to switch pagination off for the blog posts. It's trying to show page 2 of both listings, and there's no page 2 for your post.
This is part of my post.php
How to disable pagination on perch_blog_post?
You'll either need to switch to
perch_blog_custom()
or setperch_blog_post_comments
to use a differentpagination-var
option.Thanks Drew.
or set perch_blog_post_comments to use a different pagination-var option
The above is my chosen option. How can I achieve that?
Using this does not render the pagination-var value:
Using the custom does not display comment content
The point is that the two listings need different pagination var options. If you set them to the same you're back in the same position.
The thing is, pagination is only enabled in comments. Setting pagination-var in perch_blog_post_comments is not working, it still points to &page=
This is a simple task and I cannot get it to work, and it's disappointing. Maybe you can have a look at my post.php below and see what i'm doing wrong. Thanks
Post.php
Have you tried what Drew is suggesting, to set a different var for each? It's difficult to help if we don't know whether you are acting on the advice given.
I tested this and I can confirm that
perch_blog_post_comments()
seems to ignore thepagination-var
option and always uses the default?page
.Since the
pagination-var
option works inperch_blog_custom()
, change it to something other than the defaultpage
to achieve what Drew suggested; setting differentpagination-var
s for each one (your post and your comments).