Forum
Reusing An Inputted Variable In The Same Region?
I have a product listing region that asks for image, product name and description. The product name is asked for as:
<perch:content id="text" type="text" label="Product Name" required="true" title="true" />
In the same region I would like to use the product name before the words 'Feeding Guide', e.g. <h2>Product Name Feeding Guide</h2>
What Perch code snippet should I use to output the Product Name? I've tried <h2><?php perch_content('Product Name'); ?> Feeding Guide</h2> which doesn't work. I'm guessing it should involve the ID but how do I reference this correctly?
Many thanks.
Hi,
You are right you need to re-use the ID. So something like:
your-template.html
Many thanks Mike, my first time using Perch, not PHP savvy and back against the wall re deadline! I'll give that a try.
Thanks again Mike, works fine. If I can pick your brains further...
The Feeding Guide is supposed to use javascript to reveal, however for each product region added a unique ID will be required:
I've added a field to my region asking the admin to add a unique reference which would replace the number 1 in the above ID's and javascript.
So, the feeding guide is hidden however the javascript reveal link doesn't work...
Any help greatly appreciated?
Alternatively, rather than asking the Admin to enter a unique reference that is used in the Javascript and HTML template does Perch count the number of multiple items added and if so how can I draw this number in to my Javascript and HTML template?
If you add
<perch:showall />
to your template and then view the page, you will see all the ids available to use in your template. There should be an item index count in there.Hi Duncan, Robert,
Many thanks for that. Did a search of the forum for unique IDs and came across Robert's answer. Thanks again. First time using Perch with no PHP knowledge but must admit it is going well!