Forum

Thread tagged as: Problem

The template could not be found.

Hi, I want to display one random background-image from a template repeater and it gives me this error: The template <code></code> could not be found.

Template home-image.html

<perch:repeater id="aleatorio-portadas" label="Portadas">
    <perch:content type="image" id="image-carrusel-home" label="Imagen" quality="70" width="1440" help="Se recorta a 1440px de ancho" />
</perch:repeater>

Content-custom

<div class="h1" style="background-image:url('
          <?php perch_content_custom(array(
                                    'count'      => 1,
                                    'template'   => 'home-img.html',
                                    'sort'       => 'postDateTime',
                                    'sort-order' => 'RAND',
           ));?>
');">

Any idea?

Raul Serrano

Raul Serrano 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

The first argument to perch_content_custom() is the name of the region.

<?php perch_content_custom('Covers', array(
                                    'count'      => 1,
                                    'template'   => 'home-img.html',
                                    'sort'       => 'postDateTime',
                                    'sort-order' => 'RAND',
           ));?>

Like that?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, that's right.

If that's your full template above, you're sorting on a field that doesn't exist (postDateTime) so you won't get any results.

Thanks Drew — So, should I remove that 'sort' line?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, you should.