Forum

Thread tagged as: Problem

Comment app configuration

I have comment app installed, but the comment also appear on other pages.

My page template

<?php
perch_comments('subpages', [
'template' => 'comment.html',
'sort-order' => 'DESC',
]);
perch_comments_form('subpages', 'Destinations');
?>
Edward Johansen

Edward Johansen 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

the comment also appear on other pages

Can you please give a more detailed description of the issue you're trying to solve?

When I add a comment on for example page 1, the comment also appear on page 2, using the same page template.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are they all using the identifier subpages ?

Yes. Is there a way to do this dynamically. Like if you use the same page template, the rest of individual pages does not show the same comment like the blog.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, you need to use something dynamic for the identifier. The page path would work.

Can you guide me on how to accomplish that? I have never done it on Comment App.Thanks

Drew McLellan

Drew McLellan 2638 points
Perch Support

$identifier = perch_page_url([], true);
perch_comments($identifier, [ 
'template' => 'comment.html', 
'sort-order' => 'DESC', 
]); 
perch_comments_form($identifier, 'Destinations');

It does not work if it's in the same PATH url.

    /destinations/page1.html - Comment is showing
     /destinations/page2.html - Comment not displaying
     /destinations/page3.html - Comment not displaying

But if i change the path url of page3.html the comment is showing

Top page
    /page3.html - Comment not displaying

Any ideas?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, so use something else unique. It doesn't matter what it is.

Sorry, my explanation was wrong, it's the path url not order of the page. I would like to use the same path url for SEO purposes.

This does not work on multi level page. Any advice.

/destinations/level2/page1.html - Comment is showing
/destinations/level2/page2.html - Comment is showing
/destinations/level3/page2.html - Comment not displaying
/destinations/level3/page3.html - Comment not displaying
Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you show me the real values involved?

Level 2 page template

<?php perch_layout('subpages_header'); ?>
<main class="cd-main-content">

<div class="container__large">
            <div class="row pd-t-50">
                    <div class="col s12 m12 l7 xl7 pd-r-40 m-pd-r-10 m-border-r border-r spage__content">
                        <article>
                                <?php perch_content_create('Subpages left content', array(
                                'template' => 'subpages/subpages_left_column.html',
                                'multiple' => true,
                                'edit-mode' => 'listdetail',
                                'sort' => 'date',
                                'sort-order' => 'DESC',
                                'searchable' => false,
                                'filter' => 'slug',
                                'match' => 'eq',
                                'value' => perch_get('s'),
                                'count' => 1,
                                ));
                                perch_content_custom('Subpages left content', array(
                                'skip-template' => false,
                                'template'=>'subpages/subpages_left_column.html'
                                ));

                                $pagetitle = perch_pages_title(true);
                                PerchSystem::set_vars(['title_returned' => $pagetitle,
                                ]);

                                ?>
                                <?php
                                $identifier = perch_page_url([], true);
                                perch_comments($identifier, [
                                'template' => 'comment.html',
                                'sort-order' => 'DESC',
                                ]);
                                perch_comments_form($identifier, 'Parent Destination Page');

                                ?>


                    </article>
                    </div><!--* END of left main column -->

                    <div class="col s12 m12 l5 xl5 m-pd-l-10 pd-l-40 m-pd-t-40">
                        <div class="custom__tab">

                        <?php perch_content_create('Tabs title', array(
                        'template' => 'widgets/tabs_title.html',
                        'multiple' => true,
                        'edit-mode' => 'listdetail',
                        'sort' => 'date',
                        'sort-order' => 'DESC',
                        'searchable' => false,
                        ));
                        perch_content_create('Tabs content', array(
                        'template' => 'widgets/tabs_content.html',
                        'multiple' => true,
                        'edit-mode' => 'listdetail',
                        'sort' => 'date',
                        'sort-order' => 'DESC',
                        'searchable' => false,
                        ));
                        ?>

                        <?php   perch_content_custom('Tabs title', array(
                        'skip-template' => false,
                        'template'=>'widgets/tabs_title.html'
                        ));
                        ?>
                        <div class="custom__tab_content" id="boxscroll">
                                                <?php perch_content_custom('Tabs content', array(
                        'skip-template' => false,
                        'template'=>'widgets/tabs_content.html'
                        ));
                        ?>
                        </div>
                        <div class="s12 b-mask"></div>
                        </div>
                        <?php perch_content_create('Right Column Blocks', array(
                        'template' => 'subpages/right_column_blocks.html',
                        'multiple' => false,
                        'edit-mode' => 'listdetail',
                        'sort' => 'date',
                        'sort-order' => 'DESC',
                        'searchable' => false,
                        ));
                        perch_content_custom('Right Column Blocks', array(
                        'skip-template' => false,
                        'template'=>'subpages/right_column_blocks.html'
                        ));
                        ?>
                    </div><!--* END of right main column *-->

</div>
</div>

</main>
<?php perch_content_custom('footer', array(
            'skip-template' => false,
            'template'=>'shared/footer.html'
                ));
    ?>
<?php perch_layout('subpages_footer'); ?>

Level 3 page template

<?php perch_layout('subpages_details_header'); ?>
<main class="cd-main-content">

<div class="container__large">
            <div class="row">
                    <div class="col s12">

                                <?php
                                perch_content_create('Top Image', array(
                                'template' => 'subpages/revolution_details_header.html',
                                'multiple' => true,
                                'edit-mode' => 'listdetail',
                                'sort' => 'date',
                                'sort-order' => 'DESC',
                                'searchable' => false,
                                'filter' => 'slug',
                                'match' => 'eq',
                                'value' => perch_get('s'),
                                'count' => 1,
                                ));
                                perch_content_custom('Top Image', array(
                                'skip-template' => false,
                                'template'=>'subpages/revolution_details_header.html'
                                ));
                                ?>




                </div>
                </div>
                </div>
                            </div><!--* END of main column -->
                        <?php
                                    perch_content_create('Subpages left content', array(
                                    'template' => 'subpages/subpages_details_left_column.html',
                                    'multiple' => false,
                                    'sort' => 'date',
                                    'sort-order' => 'DESC',
                                    'searchable' => true,
                                    'filter' => 'slug',
                                    'match' => 'eq',
                                    'value' => perch_get('s'),
                                    'count' => 1,
                                    ));
                                    perch_content_custom('Subpages left content', array(
                                    'skip-template' => false,
                                    'template'=>'subpages/subpages_details_left_column.html'
                                    ));

                                    $pagetitle = perch_pages_title(true);
                                    PerchSystem::set_vars(['title_returned' => $pagetitle,
                                    ]);
                                    perch_content_custom('Subpages left content', array(
                                    'page'=>'*',
                                    'template'=>'widgets/rating_details_title.html',
                                    ));

                        ?>
                        <?php
                        $identifier = perch_page_url([], true);
                        perch_comments($identifier, [
                        'template' => 'comment_details.html',
                        'sort-order' => 'DESC',
                        'page'=>'*',
                        ]);
                        perch_comments_form($identifier, 'Details', array(
                        'template' => 'comment_form_details.html',
                        ));

                        ?>

</main>
<?php perch_content_custom('footer', array(
            'skip-template' => false,
            'template'=>'shared/footer.html'
                ));
    ?>
<?php perch_layout('subpages_details_footer'); ?>

Is that what you meant?

Drew McLellan

Drew McLellan 2638 points
Perch Support

I mean when you state /destinations/level3/page3.html - is that the actual path of your page or an example?

If it's not the path, what is the path?

Yes, that is the right example path.

/destinations/bohol (level 2) - Comment showing
/destinations/bohol/chocolate-hills (level 3) - Comment not showing
/destinations/bohol/chocolate-hills (level 3) - Comment not showing
/destinations/palawan (level 2) - Comment not showing

I found the problem. It does not like a path with "-" (hyphen), or a long single name (e.g. imaverylongpagename)

Any ideas?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, so you’ll need to use something else. You should be able to use the page attributes functions to get the pageID - how about that?

Sure, as long as it works. Do you have an example?

Drew McLellan

Drew McLellan 2638 points
Perch Support

perch_page_attribute('pageID, [], true);

It's all working now. Thanks Drew!

By the way, The Blog comments is showing the page title instead of using identifier. Which helps a lot when you have hundreds of pages. Is it possible with the comment app?