Forum

Thread tagged as: Error

page_content_custom tag not appearing in regions

Hi,

I'm trying to implement perch_content_custom tags in a template, but when I create a page using this template, the perch_content_custom tag doesn't appear as a region through the CMS.

This is the code I have (which is inside the <main> tags)

<?php perch_content_custom('page content', array( 'template'=>'_page_content.html', )); ?>

I've also included the following in the top of my document:

<?php perch_content_create('page content', array( 'template'=>'_page_content.html', )); ?>

Many thanks!

Darren Cusdin

Darren Cusdin 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

perch_content_custom() doesn't create new regions. It just displays existing regions.

You need to use perch_content() or perch_content_create() to create the region.

I've got perch_content_create() in the template as well as perch_content_custom() - will this cause an issue?

Drew McLellan

Drew McLellan 2638 points
Perch Support

No, that's perfect.

Is there any other reason why this couldn't be working? I've got the html file _page_content.html in the relevant folder too. It was previously working until only recently where the template wasn't altered in any way.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you show us the master page you're using?

<?php include($_SERVER['DOCUMENT_ROOT'].'/inc/header.php'); ?>
<?php
    perch_content_create('page content', array(
        'template'=>'_page_content.html',
    )); 
?>

<?php 
$page_title = perch_pages_title(true);
PerchSystem::set_var('page-title',$page_title); 
perch_content_create('page banner', array(
    'template' => '_page_banner.html',
)); 
?>
<?php perch_content_custom('page banner', array(
   'template' => '_page_banner.html',
)); 
?>

<main>
  <div class="content-wrapper">
    <div class="left-col">

        <?php perch_content_custom('sidebar widgets', array(
   'template' => '_sidebar_widgets.html',
)); 
?>


    </div>
    <!-- /div.left-col -->

    <div class="right-col">
     <?php perch_pages_breadcrumbs(); ?>
        <?php
    perch_content_custom('page content', array(
        'template'=>'_page_content.html',
    )); 
?>

    </div>
    <!-- /div.right-col --> 

  </div>
  <!-- /div.content-wrapper --> 
</main>
<?php include($_SERVER['DOCUMENT_ROOT'].'/inc/footer.php'); ?>
Drew McLellan

Drew McLellan 2638 points
Perch Support

That looks ok. If you turn debug on for the page, what does it output?

Sorry for the delayed response! This is what I get when debug is turned on for a page where the content regions aren't appearing...

Debug Message
[1] SELECT u.*, r.* FROM perch2_users u, perch2_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='c66ee7c1b14d4c56100a03b9a98504a2' LIMIT 1
UPDATE perch2_users SET userHash='f212ce433379e265697a53a79da25a16' WHERE userID='1'
[40] SELECT p.privKey FROM perch2_user_privileges p
[25] SELECT * FROM (SELECT DISTINCT settingID, settingValue, userID FROM perch2_settings WHERE userID=1 OR userID=0 ORDER BY userID DESC) AS settings GROUP BY settingID, settingValue, userID
[1] SELECT * FROM perch2_pages WHERE pageID=126 LIMIT 1
[2] SELECT * FROM perch2_content_regions WHERE pageID=126 AND regionPage!='*' ORDER BY regionOrder ASC
[0] SELECT COUNT(*) FROM perch2_content_items WHERE itemJSON!='' AND regionID=343 AND itemRev=0
[0] SELECT COUNT(*) FROM perch2_content_items WHERE itemJSON!='' AND regionID=344 AND itemRev=0
Drew McLellan

Drew McLellan 2638 points
Perch Support

What about on the front end web page itself?

Hi Drew,

I actually managed to fix this issue by creating a new template, which worked fine as the pages I was trying to create needed to be slightly different anyway. I believe the issue could have been that only a limited amount of pages were able to use one template.

Regardless, everything is working fine now - thanks for your help!

Drew McLellan

Drew McLellan 2638 points
Perch Support

I believe the issue could have been that only a limited amount of pages were able to use one template.

There's no such limitation. It must have been something else.