What is the correct method to fill the area "dynamic-data" so it displays the current uploaded image?Thanks in AdvanceDave"> CC6 show existing image when in edit view - Forums

Forums

CC6 show existing image when in edit view

Twincarb 25 Aug, 2017
Hi Max,

I am using the new CC6 (About time!) I have my CC view set up from the table and it shows the data I want to, I have an edit button which takes me to the inbuilt CC6 edit form, above the new image upload box I have a custom area which I am attempting to use php to display the currently saved image, or if it's empty it shows my blank.jpg file.

The code that I have adjusted from the original CC4/CF4 topic is:

<?php
if ( !empty($this->get("read_vehicle.Vehicle.image")) ) {
  echo "<img src='".JURI::root()."components/com_chronoforms5/chronoforms/uploads/newvehicle/ *dynamic-data*' />";
} else {
  echo "<img src='".JURI::root()."components/com_chronoforms5/chronoforms/uploads/newvehicle/blank.jpg' />";
}
?>


What is the correct method to fill the area "dynamic-data" so it displays the current uploaded image?

Thanks in Advance

Dave
Twincarb 25 Aug, 2017
Answer
I solved my issue after having a good think over the problem along with reading one of Max's other answers on a similar matter.

The essential information is the correct use of the variables when working inside PHP tags the following syntax is required:


$this->get("function Name.Model Name.field Name");


In the html element we can switch back to a normal var which is converted automatically on page load by CC6.

{var:function Name.Model Name.field Name}


The full code which I used to show the current image is below, this was inserted inside a custom element in the CC6 form, I can see no reason why the same won't apply to CF6 as well.

<label for"current-image">Current Image</label>
<?php
if ( !empty($this->get("read_vehicle.Vehicle.image")) ) {
  echo '<img src="/components/com_chronoforms5/chronoforms/uploads/newvehicle/{var:read_vehicle.Vehicle.image}" />';
} else {
  echo '<img src="/components/com_chronoforms5/chronoforms/uploads/newvehicle/blank.jpg" />';
}
?>


Max, Bob,

If you can see a way to improve my code I am all ears🙂

Regards,

Dave
Max_admin 26 Aug, 2017
Hi Dave,

The code is correct, you are missing an = here:
<label for"current-image">Current Image</label>

should be
<label for="current-image">Current Image</label>


Best regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
amheng5 15 Feb, 2019
Hi,

I can't seem to get this to work:

This is what I have:

<label for="photo_upload">Current Image<br /></label>
<?php
if ( !empty($this->get("details List name.Article.photo_upload")) ) {
echo '<img src="/components/com_chronoforms6/chronoforms/uploads/{var:details list name.Article.photo_upload}" />';
} else {
echo '<img src="/components/com_chronoforms6/chronoforms/uploads/blankhead.gif" />';
}
?>

But nothing appears or my blankhead.gif appears even if I know an image exists for the record.

Where am I going wrong? I've tried using table name in place of details list name and still nothing
Thanks
healyhatman 15 Feb, 2019
Put a {debug:} on that page and post the results here please
amheng5 15 Feb, 2019
Sorry..don't know how to get the debug feather to work. i'll provide as soon as I can. thanks
healyhatman 15 Feb, 2019
You know how you do {fn:read data} ??? After all that put {debug:}
amheng5 16 Feb, 2019
I've resolved my issue. Didn't realize I needed to Retrieve my fields in the detail list. Now I need to figure out how to replace image uploaded using CF6 for an existing record or upload a new image in an existing record.
Max_admin 19 Feb, 2019
@amheng5, just upload a new image and update the extisting record with a "Save data" passing the record's primary key value.
​
Best regards
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.