VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: AbsoluteVM on May 10, 2012, 10:22:54 AM

Title: Related products layout
Post by: AbsoluteVM on May 10, 2012, 10:22:54 AM
I am trying to reference a products image in the related products template, default_relatedproducts.php

obviously $this->product->image[0]->file_url references the current products im viewings image url, but I need to grab the image of the related product.

Ideally I want to output related products in a floated div and manipulate them with a jQuery carousel.

Sadly, I can't work out where I can reference whats going on. I have this output:

<span class="product-field-display">
<a title="Related Product" href="x"><img alt="" src="http://mysite.com/components/com_virtuemart/assets/images/vmgeneral/filetype_jpg.png"> Related Product </a>      
</span>

I've got some custom paths to my images, using a php thumbnail generation script.

How can I reference the products image for related products and get access to all its variables?
Title: Re: Related products layout
Post by: AbsoluteVM on May 10, 2012, 12:47:35 PM
So the problem is when I want to reference the product->variables, its referencing the current product detail page i'm on, not the related product.
Title: Re: Related products layout
Post by: AbsoluteVM on May 10, 2012, 15:07:42 PM
It's also outputting http://mysite.com/components/com_virtuemart/assets/images/vmgeneral/filetype_jpg.png instead of my product image..
Title: Re: Related products layout
Post by: PRO on May 10, 2012, 18:13:59 PM
http://forum.virtuemart.net/index.php?topic=100696.0


$this->     refers to the ID thats in the url.

Title: Re: Related products layout
Post by: AbsoluteVM on May 11, 2012, 11:25:48 AM
I can't refer to it by using $product->product_name

I can't refer to anything in the default_relatedproducts.php :/

$field->display outputs the related product
Title: Re: Related products layout
Post by: AbsoluteVM on May 11, 2012, 15:07:57 PM
How am I supposed to customise <?php echo $field->display ?>
Title: Re: Related products layout
Post by: PRO on May 11, 2012, 15:16:55 PM
field->display is the HTML

Title: Re: Related products layout
Post by: Smook on May 12, 2012, 21:27:23 PM
But over it is HTML (link with image) and how and where I can customize it ?
EG:
<a href="#" title="Title"><img src="/images/stories/virtuemart/product/xxx.jpg" alt="xxx"><span class="vm-img-desc">xxx</span> xxx</a>
Title: Re: Related products layout
Post by: AbsoluteVM on May 14, 2012, 11:27:17 AM
BanquetTables, how do you customise the output of field->display? Where is that code located, outside of the core in inside?
Title: Re: Related products layout
Post by: AbsoluteVM on May 14, 2012, 11:39:43 AM
This controls the fields->display

            $field->display = $this->displayType($field->custom_value,$field->field_type,$field->is_list,$field->custom_price,$row,0);

Line 556 of customfields.php.

I don't know why default_relatedproducts.php is not other templating systems. Would it not be much BETTER to have this in a template, like default.php where I can use all product variables..

Can anyone answer, how can I modify how it outputs the related product structure, the curremlt HTML is not good enough.. ?
Title: Re: Related products layout
Post by: AbsoluteVM on May 21, 2012, 11:15:03 AM
Any ideas ?
Title: Re: Related products layout
Post by: PRO on May 21, 2012, 11:40:27 AM
no idea
Title: Re: Related products layout
Post by: AbsoluteVM on May 21, 2012, 13:39:49 PM
So people just put up with the output as stock?
Title: Re: Related products layout
Post by: AbsoluteVM on May 24, 2012, 11:21:15 AM
lol. :(
Title: Re: Related products layout
Post by: nick_iFactory on September 20, 2013, 09:09:04 AM
Was able to get a reference to the related product using these lines in the foreach loop and then could get data out and use it like a regular template... probably not the best way of doing things though.

$productModel = VmModel::getModel ('product');
$relative = $productModel->getProduct ($field->custom_value);
      
$imageModel = VmModel::getModel('media');
      
$images = array();
foreach($relative->virtuemart_media_id as $cur_image) {
   $imageModel->_id = $cur_image;
   $images[] = $imageModel->getFile();
}