VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: Ihateit on November 20, 2012, 13:30:52 PM

Title: "Go to product" in "Related Products"-view
Post by: Ihateit on November 20, 2012, 13:30:52 PM
Hey Forum,

as the topic headline states, i would like to know how to add a "Go to product" button for each of the "Related Products". I've a few different things like:
<?php // Product Details Button
   echo JHTML::link($product->link, JText::_('COM_VIRTUEMART_PRODUCT_DETAILS'), array('title' => $product->product_name,'class' => 'product-details'));
?>

and
<a href="<?php echo JHTML::link($product->link); ?>" class="product-details-button"><?php echo JText::_('COM_VIRTUEMART_PRODUCT_DETAILS'); ?></a>

which of nothing worked.. :(

What should i add to get this working?

//Ihateit


Mod edit:  impatient bump message removed.  http://forum.virtuemart.net/index.php?board=114.0
Title: Re: "Go to product" in "Related Products"-view
Post by: bytelord on November 20, 2012, 15:45:43 PM
Hello,

I can give one method for default_relatedproducts.php but without category link on the path

<?php
 $url 
JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' $field->custom_value);
 echo 
JHTML::link ($urlJText::('COM_VIRTUEMART_PRODUCT_DETAILS'), array('title' => '''class' => 'product-details'));
?>


May be someone lese have a better idea.

Regards
Title: Re: "Go to product" in "Related Products"-view
Post by: PRO on November 20, 2012, 19:14:30 PM
default_relatedproducts.php

after
  foreach ($this->product->customfieldsRelatedProducts as $field) {

add
$field->display = str_replace( '</a>', '<br/>Go to Product</a>', $field->display );
Title: Re: "Go to product" in "Related Products"-view
Post by: Ihateit on November 22, 2012, 11:54:35 AM
Thanks a lot guys! Used bytelords suggestion, and it works flawlessly :-)

Another thing, i would like to move the name of the product above the image, instead of under. Where do i change this?

//Anders J.
Title: Re: "Go to product" in "Related Products"-view
Post by: Ihateit on November 22, 2012, 15:51:46 PM
In the default_relatedproducts.php there is a line saying "echo $field->display", displaying the image-link and productname-link under the image. But i dont know where do edit these info. Because i cant make the productname-link be shown above the image.

It is really starting to irritate me :-D Have searched the web thin, trying to find it...

//Anders J.
Title: Re: "Go to product" in "Related Products"-view
Post by: fastestpc on May 17, 2013, 16:10:12 PM
Quote from: PRO on November 20, 2012, 19:14:30 PM
default_relatedproducts.php

after
  foreach ($this->product->customfieldsRelatedProducts as $field) {

add
$field->display = str_replace( '</a>', '<br/>Go to Product</a>', $field->display );

thank you for your nicecode

I want to replay the product name in Related prouducts. how i can? I want inserct <div> tag before the product name. I have test with this code but It not ok.

$field->display = str_replace( $this->product->product_name,'<div class="productname">'.$this->product->product_name.'</div>', $field->display );

Have any one help me.
Title: Re: "Go to product" in "Related Products"-view
Post by: PRO on May 17, 2013, 17:34:26 PM
fastest, what exact you trying to do?

make it look better?

I use this

<?php $field->display = str_replace( '"  />', '"  /><br/>', $field->display ); ?><?php echo $field->display; ?>
Title: Re: "Go to product" in "Related Products"-view
Post by: fastestpc on July 06, 2013, 04:44:19 AM
Quote from: PRO on May 17, 2013, 17:34:26 PM
fastest, what exact you trying to do?

make it look better?

I use this

<?php $field->display = str_replace( '"  />', '"  /><br/>', $field->display ); ?><?php echo $field->display; ?>

Thank you for your code, it look better true