Forum

Thread tagged as: Question, Problem

perch_content_custom in template

Have a testimonial section very much like the sample video. Followed creating a random display of 3 using perch_content_custom but none show only part of the code and page source shows full php code.Sample page (at foot):- https://webmedia.webhop.biz/whycallanetics/

Custom code added in block (3-col-testimonial-block.html)

<div class="row">
  <div class="panel-3">
      <?php perch_content_custom('testimonials', array(
            'page'=>'testimonials.php',
            'template'=>'_3-testimonials.html',
            'sort'=>'name',
            'sort-order'=>'RAND',
            'count'=>3,
            )); 
      ?>
    <div class="testimonial"><a href="/testimonials" title="Read all testimonials">See all testimonials</a></div>
  </div>
</div>

_3-testimonials.html

<div class="medium-4 columns block">
    <blockquote><perch:content id="testimonial" type="text" label="Testimonial" markdown="true" editor="markitup" required="true" chars="140" append=" ..." />
    <cite><perch:content id="name" type="text" label="Name" markdown="true" editor="markitup" required="true" />&nbsp;&nbsp;&nbsp;<img src="/images/end-quote.png"></cite>
    </blockquote>
</div>

testimonials.php

<?php if (!defined('PERCH_RUNWAY')) include($_SERVER['DOCUMENT_ROOT'].'/perch/runtime.php'); ?>
<?php perch_layout('global-top');
?>
<div class="row">
    <div class="medium-4 columns">
        <?php perch_content('testimonial-image'); ?>
    </div>
    <div class="medium-8 columns">
        <h1><?php perch_content('text'); ?></h1>
        <div class="testimonials">
            <?php perch_content('testimonials'); ?>
        </div>
    </div>
</div>
<?php perch_content('call-to-action-block'); ?>
<?php perch_layout('global-bottom'); ?>

Not sure what doing wrong!

Rob Willox

Rob Willox 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

It looks like your page isn't parsing as PHP for some reason.

Looks like it, but parsing rest of page so can't see why not!

Drew McLellan

Drew McLellan 2638 points
Perch Support

Oh wait - you're using PHP in your template. You can't do that. PHP goes in the page - pass the result into the template.

That would explain it. Was about to post that had added pagination to the testimonials page and everything parsed ok but had obviously modified the PHP in the page.

Not sure what needs to be added to the template. It's a block template and added as optional content to different pages. Also, as using original modified testimonials page for the pagination will a copy have to be made as the attributes are different for this block.

What trying to achieve is randomly display 3 testimonials across the page in the block. Maybe over-complicating this but not seeing how to get the template for the 3 testimonials into the block template.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I can't think of a way to do that within a block.

If a new page was created with individual regions from a new master page rather than added via a blocks template would that help?

Or, is the easiest way to just enter them manually in the block template?

Drew McLellan

Drew McLellan 2638 points
Perch Support

I can't think of a way to dynamically pull content from another region into the current region without using Relationships, which are a Runway feature.

Unfortunately, site not large enough to justify Runway; manually probably the simplest to implement and get going with.