Forums

Dynamic image and name in form and email

marco09 06 Dec, 2015
Hi,

in a classical products site (the product page is a Joomla article page, with title=product name and product image and other informations), I put a "Info about this product" button linked to a Chrono form.

In this form I need to have the name and the image of the product (they are present in the product article Joomla page). These 2 informations must be present in the form dynamically.

You may see at this url: http://2015.bioemotions.it/biocamini/biocamini-per-esterni/24-bioemotions/bioemotions-prodotti/biocamini/biocamini-per-esterni/66-nice
Now the name is loaded with the name of the product (Nice) in the button link and the image is a constant (not good).

There is a demo for my question or other resources to resolve it? Thanks.
GreyHead 06 Dec, 2015
HI Marco,

Assuming that the product name is unique it will be available in the $form->data array of the form and you can load an image in a Custom Code element in the Designer tab using HTML like this:
<img src='/images/bioemotions/prodotti/esterni/{product}.jpg' >
If the image and product names do not all match exactly then you can look them up from an array or a DB Read.

Bob
marco09 07 Dec, 2015
Thanks SilverHead,

in this mode the thing works but it isn't a dynamic solution; I have to change, for every product, the code in the "request informations for this product" button.

Now I study the "DB read" statement to see if it is possible to get the name and image path from the DB.

By and thanks!
GreyHead 07 Dec, 2015
Hi marco09,

ChronoForms has no magic way of knowing reliably which page the form was linked from unless the data is in the link. You need some code in the product page to identify the product in the link.

+ You can do that manually

+ You could use JavaScript to read something in the page info and add the product id to the link.

+ You could embed a form with just a button and include some PHP in that to add the product id in a hidden input.

Bob
This topic is locked and no more replies can be posted.