SOLVED Products Module Accessing _products/ Topic is solved

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
montedavis
Forum Members
Forum Members
Posts: 64
Joined: Wed Jul 03, 2013 7:44 pm

SOLVED Products Module Accessing _products/

Post by montedavis »

Hello,

I'm using the products module and I'm trying to make image management easy for my client by having them upload images via a custom field definition named "case-study-detail-image"

When an image is uploaded the name of the image is added as the field value, which makes sense. I'm having trouble displaying the actual image on the frontend of the site as I don't know how to access the directory where the image is stored. If I go to the "fields" tab of an item I can see the name of the image and if I hover over the image I can see the path to the upload directory for that specific product image:

/uploads/_products/product_1/product_1_image.jpg

How do I find the smarty variables to construct the path?

I tried adding the following troubleshooting tags but did not see the image path.
{get_template_vars}
{$var|print_r}
{$item|print_r}
{$entry|print_r}

I understand I could use the "images" tab but adds images to an "album" and I don't understand how to pull a specific image from the album images array, and it may be too confusing to explain how to use multiple images to the client.

Thank you,

Monte
Last edited by montedavis on Wed Nov 11, 2020 4:05 pm, edited 1 time in total.
montedavis
Forum Members
Forum Members
Posts: 64
Joined: Wed Jul 03, 2013 7:44 pm

Re: Products Module Accessing _products/

Post by montedavis »

I figured it out...

{if !empty($entry->fields)}
{foreach from=$entry->fields item='field'}
{if $field->name == 'case-study-detail-image'}
<div class="case-study-image"><img class="case-studies-detail-image" src="/{uploads_url}/_products/product_{$entry->id}/{$field->value}"><div>
{/if}
{/foreach}
{/if}
Locked

Return to “CMSMS Core”