VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: EvanGR on September 12, 2019, 15:36:26 PM

Title: Accessing image URLs in related products
Post by: EvanGR on September 12, 2019, 15:36:26 PM
How do I access the image URLs (full image and thumbnail), in the template?

In the commercial template I am tweaking, there's a related.php file in sublayouts folder;
A related product is defined in there. But it gets the data like so:

$related = $viewData['related'];
$customfield = $viewData['customfield'];
$thumb = $viewData['thumb'];


The $thumb variable holds the full img element, I just want the URLs.

(I will also need to extract other product data, so please point me to a resource or documentation if there is any)

Thanks!
Title: Re: Accessing image URLs in related products
Post by: Milbo on September 12, 2019, 15:42:41 PM
just enable the virtuemart debug and add
vmdebug('my viewData here',$viewData)
Title: Re: Accessing image URLs in related products
Post by: EvanGR on September 13, 2019, 09:40:08 AM
Quote from: Milbo on September 12, 2019, 15:42:41 PM
just enable the virtuemart debug...

For the sake of clarity, are you referring to the debug checkboxes in Shop->Advanced Settings?
Title: Re: Accessing image URLs in related products
Post by: GJC Web Design on September 13, 2019, 10:10:27 AM
yes
Title: Re: Accessing image URLs in related products
Post by: PRO on September 13, 2019, 22:18:50 PM
what are you trying to do?
Title: Re: Accessing image URLs in related products
Post by: EvanGR on September 16, 2019, 08:40:02 AM
Trying to get the URLs for a product's images and thumbnails.

In an older VM e-shop I could use the $product object and find the data.

This newer template uses 'sublayouts', and it's not clear to me how to reference the product's data.

Title: Re: Accessing image URLs in related products
Post by: GJC Web Design on September 16, 2019, 10:07:05 AM
If the full urls are not passed thru the $viewData object then u don't have to use the sublayout in your template

You can just use the code as u did before ( directly using the $product)  - but chk first if the urls are in the $viewData
Title: Re: Accessing image URLs in related products
Post by: EvanGR on September 17, 2019, 09:07:35 AM
Thanks,

The sublayout is already used because it's a 3rd party template. So I am starting from there.