Forum

Thread tagged as: Problem

perch_content_custom in Page not showing as new region in backend

I have added a content to the page, but it is not showing in backend as new region. In the content, I have added perch member has tag to rectrict viewing for members with insufficient credential or tag.

Page

 <?php perch_content_custom('profile_private'); ?> 

Content

<perch:member has-tag="officer">
<div class="col-sm-8 col-md-8 col-lg-8 bor-wrap bc-gray nopad br-3 pull-right mr-top-20">
<h4 class="fs-26 fc-dgray bor-bot"><perch:content id="PriInfoTitle" type="text" label="Private Profile info" required="true" title="false" /></h4>
<perch:repeater id="Priprofileinfo" label="Labels">
 <p class="bg-white cs-one"><strong><perch:content id="PrivateInfoLabels" type="select" label="Private Profile label"
options="Home number, Mobile Number,#1 Contact name, #1 contact number,Home address,Bank account number" allowempty="false" required="false" />:</strong> <span style="padding-left:10px"><perch:content id="profileInfotext" type="text" label="Label content" required="true" title="false" /></span></p>
</perch:repeater>
<div class="col-lg-12 profile-about-me">
<perch:content id="PriMoreInfo" type="textarea" label="Other information" markdown="true" editor="markitup" imagewidth="640" imageheight="480" />
</div>
</div>
</div></perch:member>
Edward Johansen

Edward Johansen 0 points

  • 4 years ago
Simon Clay

Simon Clay 127 points

Have you tried <?php perch_content('profile_private'); ?> reload the page then check backend?

You'd not usually use perch_content_custom unless you're setting special options.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

perch_content_custom does not define new regions https://docs.grabaperch.com/functions/content/perch-content-custom/

@Simon When i define <?php perch_content('profile_private'); ?> the region is visible to perch:member has-tag="officer", also added into the backend to edit the region.

If you can guide me on how to protect a region to be hidden if a member is logged in with the pre-defined tag to view the spesific content would be really helpful.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

If you want to create the region programmatically then you can use perch_content_create - this is detailed on the documentation link I posted earlier in the thread, but just using perch_content_custom is not going to create your region. You need to create it in some way first - as that page explains.

That is working fine. But the content wrapped is not showing even though the member logged in has the tag.

<perch:member has-tag="officer">
<div> Content to show if the member has the 'officeer' tag</div>
</perch:member>

Sorted. But the is a </perch:member> showing in the source code.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

You will need to show us more of your template/page code and your Diagnostics Report for us to do more than make guesses.

Template code

<perch:member has-tag="officer">
<div class="col-sm-8 col-md-8 col-lg-8 bor-wrap bc-gray nopad br-3 pull-right mr-top-20">
<h4 class="fs-26 fc-white bc-blue1 bor-bot"><perch:content id="PriInfoTitle" type="text" label="Private Profile info" required="true" title="false" /></h4>
<perch:repeater id="Priprofileinfo" label="Labels">
 <p class="bg-white cs-one"><strong><perch:content id="PrivateInfoLabels" type="select" label="Private Profile label"
options="Home number, Mobile Number,#1 Contact name, #1 contact number,Home address,Bank account number" allowempty="false" required="false" />:</strong> <span style="padding-left:10px"><perch:content id="PriprofileInfotext" type="text" label="Label content" required="true" title="false" /></span></p>
</perch:repeater>

<div class="col-lg-12 profile-about-me">
<perch:content id="PriMoreInfo" type="textarea" label="Other information" markdown="true" editor="markitup" imagewidth="640" imageheight="480" />
</div>
</div>
</perch:member>

Diagnostics

Perch Runway: 2.8.32, PHP: 5.6.27, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: xxxx8b24596e12d4553bd41fc93cccd5bac2xxxx $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.32), assets (2.8.32), categories (2.8.32), perch_blog (5.0), perch_members (1.5)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_members', 'perch_blog', );
PERCH_LOGINPATH: /pwcms
PERCH_PATH: /var/www/vhosts/mysite.com/httpdocs/pwcms
PERCH_CORE: /var/www/vhosts/mysite.com/httpdocs/pwcms/core
PERCH_RESFILEPATH: /var/www/vhosts/mysite.com/httpdocs/pwcms/resources
Image manipulation: GD Imagick
PHP limits: Max upload 2M, Max POST 8M, Memory: 128M, Total max file upload: 2M
F1: 2edba60ed1f613d6dd804feb202456a2
Resource folder writeable: Yes
SCRIPT_NAME: /pwcms/core/settings/diagnostics/index.php
REQUEST_URI: /pwcms/core/settings/diagnostics/
DOCUMENT_ROOT: /var/www/vhosts/mysite.com/httpdocs
HTTP_HOST: mysite.com
Drew McLellan

Drew McLellan 2638 points
Perch Support

Looks ok - which function are you using to display this template?

This is the part of the page to display it.

    <?php if (perch_member_has_tag('officer')) {
    perch_content('profile_private');
};
?>
 <?php perch_content_create('profile_private', array(
    'template' => 'profile_private.html',
    'multiple' => true,
    'edit-mode' => 'listdetail',
    'sort' => 'date',
    'sort-order' => 'DESC',
    'roles' => 'officer',
    'searchable' => false,
));
?>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you use perch_content_custom() instead of perch_content() here?

 if (perch_member_has_tag('officer')) { 
    perch_content_custom('profile_private', []); 
}

perch_content() is cached at edit time, whereas perch_content_custom() is rendered live.

@Drew Excellent. That worked, Thanks.