Forum
Duplicate content (hidden id)
Hi,
I have the following Perch HTML templates:
<perch:if exists="intro"><p><perch:content id="intro" type="text" label="Introductory Paragraph"/></p></perch:if>
and
<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
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.
Regards
Garth,
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.
RK
Hi Robert,
I will do my best.
Before anything I have (global.inc):
Next I have:
The .html template for the first
perch_content_create()
statement is:The second .html template for the second
perch_content_create()
statement: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:
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:
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.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'.