Forum

Thread tagged as: Problem

Listing/Detail Pages | Content not displaying on Detail page.

Got a bit of a weird one. Built a listing/detail page over two pages. The listing page works fine, and the link also works, taking you to a page that displays the code that’s included in the layout.

But when you go to the details page, the content from the template isn’t displayed.

I've followed the two tutorials: https://docs.grabaperch.com/perch/content/functions/how-do-i-create-list-detail-pages/ https://docs.grabaperch.com/perch/content/functions/two-page-list-and-detail/

I've managed to get them working on another install. But when I've gone to amend the code for the site I'm working on, it's not working as it should.

Here's the code from the relevant pages and templates:

/case-studies/index.php

<?php include($_SERVER['DOCUMENT_ROOT'].'/controlpanel/runtime.php'); ?>
<?php perch_layout('header'); ?>
<?php perch_layout('topbar'); ?>

  <?php perch_content_create('Case Studies', array(
    'template' => 'project_item.html',
    'multiple' => true,
    'edit-mode' => 'listdetail',
  )); ?>

  <?php perch_content_custom('Case Studies', array(
    'template' => 'project_listing.html',
  )); ?>

<?php perch_layout('footer'); ?>

/case-studies/project.php

<?php include($_SERVER['DOCUMENT_ROOT'].'/controlpanel/runtime.php'); ?>
<?php perch_layout('header'); ?>
<?php perch_layout('topbar'); ?>

  <?php perch_content_create('Case Studies', array(
    'page'     => '/case-studies/index.php',
    'template' => 'project_item.html',
    'filter'   => 'slug',
    'match'    => 'eq',
    'value'    => perch_get('s'),
    'count'    => 1,
  )); ?>

<?php perch_layout('footer'); ?>

Templates content/project_listing.html

<perch:before>
  <ul class="latest-projects row small-up-1 medium-up-2 large-up-4">
</perch:before>

  <li class="project column">
    <a href="/case-studies/project.php?s=<perch:content id="slug" for="title" type="slug" />">
      <img src="<perch:content id="featuredImage" type="image" label="Featured image" />" alt="<perch:content id="title" type="text" required="true" title="true" />">
      <h3 class="title title--project-name"><perch:content id="title" type="text" required="true" title="true" /></h3>
    </a>
  </li>

<perch:after>
  </ul>
</perch:after>

content/project_item

<perch:content id="title" type="text" label="Project Name" suppress="true" />

<div class="row">
  <div class="small-12 medium-6 columns">
    <img src="https://www.placehold.it/600x400" alt="">
    <div class="thumbs row small-up-3">
      <div class="column">
        <img src="https://www.placehold.it/600x400" alt="">
      </div>
      <div class="column">
        <img src="https://www.placehold.it/600x400" alt="">
      </div>
      <div class="column">
        <img src="https://www.placehold.it/600x400" alt="">
      </div>
    </div>
  </div>
  <div class="small-12 medium-6 large-5 large-offset-1 columns">
    <h2 class="subtitle subtitle--case-study-category"><perch:content id="project-type" type="select" label="What type of project is this?" options="Grounds Design and Development, Grounds Maintenance" allowempty="false" required="true" /></h2>

    <perch:content id="overview" type="textarea" label="Overview of the project" html="true" editor="redactor" required="true" />

    <h3 class="subtitle subtitle--case-study">What was the problem?</h3>
    <perch:content id="problem" type="textarea" label="What was the problem?" html="true" editor="redactor" required="true" />

    <h3 class="subtitle subtitle--case-study">What solution did you provide?</h3>
    <perch:content id="solution" type="textarea" label="What solution did you provide?" html="true" editor="redactor" required="true" />

    <h3 class="subtitle subtitle--case-study">What was the outcome?</h3>
    <perch:content id="outcome" type="textarea" label="What was the outcome?" html="true" editor="redactor" required="true" />

    <div class="project-meta">
      <p><strong>Skills:</strong> </p>
      <p><strong>Client:</strong> <perch:content id="heading" type="text" label="School Name" required="true" title="true" /></p>
      <p><strong>Budget:</strong> <perch:content id="budget" type="select" label="Budget of the project" options="Under £5000, £5000 to £10000, £10000 to £15000, £15000 to £20000, Over £25000" allowempty="false" required="true" /></p>
    </div>

    <perch:after>
      <perch:if exists="paging">
        <div class="paging">
          Page <perch:content id="current_page" type="hidden" /> of <perch:content id="number_of_pages" type="hidden" />
          <perch:if exists="not_first_page">
            <a href="<perch:content id="prev_url" type="hidden" encode="false" />">Previous</a>
          </perch:if>
          <perch:if exists="not_last_page">
            <a href="<perch:content id="next_url" type="hidden" encode="false" />">Next</a>
          </perch:if>
        </div>
      </perch:if>
    </perch:after>

    <perch:content id="featuredImage" type="image" label="Featured Image" suppress="true" />
    <perch:content id="slug" for="title" type="slug" suppress="true" />

  </div>
</div>

I've got debugging enabled too:

Debug Message
[1] SELECT * FROM perch2_pages WHERE pagePath='/case-studies/project.php' LIMIT 1
[7] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 ORDER BY pageTreePosition ASC
[0] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/case-studies/project.php' LIMIT 1
[5] Using template: /templates/navigation/item.html
[nil] SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/case-studies/project.php' OR regionPage='*' ORDER BY regionPage DESC
[1] SELECT pageID FROM perch2_pages WHERE pagePath='/case-studies/index.php' LIMIT 1
INSERT INTO perch2_content_regions(regionKey,regionPage,regionHTML,regionOptions,regionTemplate,regionNew,regionMultiple,regionSearchable,pageID) SELECT 'Case Studies' AS regionKey,'/case-studies/index.php' AS regionPage,'<!-- Undefined content: Case Studies -->' AS regionHTML,'[]' AS regionOptions,'project_item.html' AS regionTemplate,0 AS regionNew,0 AS regionMultiple,1 AS regionSearchable,'20' AS pageID FROM (SELECT 1) AS dtable WHERE ( SELECT COUNT(*) FROM perch2_content_regions WHERE regionKey='Case Studies' AND (regionPage='/case-studies/index.php' OR regionPage='*') )=0 LIMIT 1
UPDATE perch2_content_regions SET regionOrder=0 WHERE regionPage='/case-studies/project.php' AND regionKey='Case Studies' LIMIT 1

I get the impression the template isn't finding the content in the database – it is there – and that's why it's going to the template, but not displaying it.

Anyone come across a similar issue and resolved it?

Ben Furfie

Ben Furfie 3 points

  • 4 years ago
Ben Furfie

Ben Furfie 3 points
Registered Developer

Never mind. I was being an idiot.

Notice in /case-studies/project.php? I'm calling the wrong function (perch_content_create instead of perch_content_custom).

At least I'm not going mad :p