Forum
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.
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.
Is this when creating new pages from the Control Panel?
Yes, that is my goal.
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?
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.