Forum

Thread tagged as: Question, Installation, Configuration

Auto Connect Template to

How do I auto connect a Perch template to a content region? My goal is to have my content regions already connected to a template without requiring my editors to pick the template from the Perch regions dropdown.

Ryan McGuire

Ryan McGuire 0 points

  • 6 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

Is this when creating new pages from the Control Panel?

Yes, that is my goal.

Drew McLellan

Drew McLellan 2638 points
Perch Support

You need to use perch_content_create() in your page:

https://docs.grabaperch.com/docs/developers/creating-regions/

I think I'm doing something wrong.

I auto added the templates to my page using

<?php perch_content_create('Property Intro', array( 'template' => 'listing_intro.html', )); ?>

It shows up in the Perch Control Panel and I'm able to add content, but when I publish it doesn't show up on the page.

If I use the standard method:

<?php perch_content('Intro'); ?>

and select my template from the dropdown, add content, and publish, my content does show up on the page.

How do I fix the issue with using perch_content_create so when I publish content that it appears on the webpage?

Drew McLellan

Drew McLellan 2638 points
Perch Support

You need both! perch_content_create() does nothing but create the region. You then need to display it.

Good to know.

Just updated my code to include:"

<?php perch_content_create('Property Intro', array( 'template' => 'listing_intro.html', )); ?> <?php perch_content('Property Intro'); ?>

and it worked like a charm ;)

Thanks for your help.