Forum

Thread tagged as: Question

Reuse region to Perch Comment App

Is it possible to reuse a region to comment page? I would like to have it automatically appear, for ex: itemprop for product tittle

<perch:content id="SubpageH1Title" type="text" label="Main H1 Title" required="true" title="true" />
Edward Johansen

Edward Johansen 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, you can use perch_content_custom() to redisplay a region from a different page.

But how can you do that in comment app?

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

Drew McLellan 2638 points
Perch Support

Output the result to a variable (setting the 3rd argument in perch_content_custom() to true) and then pass that into the comment template.

Can you give me an example ? thanks

Let's say, In the same page I want my H1 heading to be displayed in the comment as the product/service name <h3 itemprop="itemreviewed">repeat the H1 title here </h3>

Got it.

Main template:

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

Comment template

<h5><perch:comments id="title_returned" html="true" /></h5>