Thread tagged as: Question

Duplicate content (hidden id)


I have the following Perch HTML templates:

<perch:if exists="intro"><p><perch:content id="intro" type="text" label="Introductory Paragraph"/></p></perch:if>


<perch:if exists="intro"><p><perch:content id="intro" type="hidden"/></p></perch:if>

which are referenced from:

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

in PHP, that is derived from:

<?php perch_content_create('intro_content',array('template'=>'introduction.html'));?>

however I am hoping to be able to use a Perch Variable as per here:

<?php PerchSystem::set_var('introduction','intro');?>

which results in nothing, i.e. it does not print twice to the screen.

Thanks for any guidance offered.

P.S. The type="hidden" field in the second code example is from introduction.html

Garth Holmes

Garth Holmes 0 points

  • 4 years ago

Your set_var is setting a value of "intro" to variable named "introduction".

Hi Robert,

Thank you for pointing that out, so simply using a keyword does not set a variable as per data in a content region and now I'm wondering how this might be achieved.



I don't think you can have a variable with (2) types (text and hidden)

In your perch:if exists"intro" you have a type of "hidden" but it would already be hidden by the perch:if if it didn't exist...

I think it would be a bit more helpful if you provide a sample bit of code (html) showing what your expected output should be, and then I may be able to better assist you on this.


Hi Robert,

I will do my best.

Before anything I have (

<?php include($_SERVER['DOCUMENT_ROOT'].'/perch/runtime.php');?>
<?php header('Last-modified: . the_modified_date()');?>
<?php PerchSystem::set_var('heading2','Website Name');?>
<?php PerchSystem::set_var('heading3',perch_pages_title(true));?>

Next I have:

<?php include('../../_includes/');?>
<?php set_include_path($_SERVER['DOCUMENT_ROOT']);?>
<?php perch_content_create('section_content',array('shared' => true,'template'=>'_section_content.html'));?>
<?php perch_content_create('intro_content',array('template'=>'introduction.html'));?>

The .html template for the first perch_content_create() statement is:

<p><perch:content id="intro" type="text" label="Introductory Paragraph"/></p>

The second .html template for the second perch_content_create() statement:

<p><perch:content id="intro" type="hidden" label="Introductory Paragraph"/></p>

I can access the variables heading2 and heading3 but have no idea of how it may or may not be possible to set a variable for the content of a region, i.e. a string that I suppose would be created much later in the compiling or run time stage.

As far as output:

<p>Terms and Conditions of our Services.</p>
<div class="breadcrumb"><ul><li><a href="/information/"><span>information</span></a><span> ></span> </li><li><span>terms</span></li></ul></div>

On large screens I'd like the content to be shown in the first <p></p> and on phones etc., I'd like to have content in the second <p></p> using CSS Media Queries but I get nothing. I tried using a slug but only obtained a reference.

Thanks again

I used this:

<?php perch_content_custom('section_content',array('template'=>'introduction.html',));?>

and it's working so I suppose you cannot use regions via perch_content_create() which makes sense as the region may not have been instanced, e.g. via data entry.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I've no idea what you're trying to do, but it's working now?

hi Drew,

Yes actually, I am confused no longer so I hope this doesn't deter anyone from using Perch CMS because it is really quite easy with a basic understanding and the fact that I can create sites on localhost before commissioning them, what an awesome product!

Quite happy with v3, I can now experiment with templates without having to rebuild an entire site just because of some naming convention I need to keep between Perch templates and others'.