Forum

Thread tagged as: Problem, Error

Template not found, when switching from perch_content to perch_content_custom

I have set up a Perch installation (latest release), put together a template and entered some content to a multi item region.
Outputting that content with perch_content works fine. Item after item are displayed one after the other as expected.
As soon as I switch to perch_content_custom to add some options like so

perch_content_custom('main_content', array());

I get the error message "The template main.html could not be found."
Adding options like

perch_content_custom('main_content', array(
  'count' => 1
));

doesn't help.
What is happening here?

Nils Mielke

Nils Mielke 3 points

  • 5 years ago
Simon Clay

Simon Clay 127 points

Does adding

'template'=>'main.html',

help?

Nope, tried that too. But thanks anyway.

Simon Clay

Simon Clay 127 points

Sure :) I had to ask.

The error message sounds like it's looking for main.html but not finding it in perch/templates/content. Double check to make sure it's in there.

If it's not there, perch_content would still work I think, because Perch saves the whole html for that region to the database. If you go to the edit page does it say main.html can't be found?

What does debug show?

Rachel Andrew

Rachel Andrew 394 points
Perch Support

If you enable debug you'll be able to see what template it is trying to use.

Tried that too. Unfortunately it doesn't output anything at all.
In the backend it shows, though, so it should work.
When looking at debug in the backend, inside the region I am working in, it states

Using template: /templates/content/main.html
Rachel Andrew

Rachel Andrew 394 points
Perch Support

Have you added the line to your page to output debug?

https://docs.grabaperch.com/docs/installing-perch/configuration/debug/

Yes, I did—as stated in the docs page you provided.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Well if you are really getting "nothing" then you have a bigger problem. I'd suggest checking your PHP error log to find out why your page is terminating.

Will do and report here. Thanks, Rachel.

Huh, just solved the issue. (I was on vacation in the meantime.)
The Perch runtime was called with

<?php include($_SERVER['DOCUMENT_ROOT'].'/perch/runtime.php'); ?>

After removing the $_SERVER bit and the first / like so

<?php include('perch/runtime.php'); ?>

everything is working and back to normal.