News:

Looking for documentation? Take a look on our wiki

Main Menu

"Go to product" in "Related Products"-view

Started by Ihateit, November 20, 2012, 13:30:52 PM

Previous topic - Next topic

Ihateit

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

bytelord

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
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

PRO

#2
default_relatedproducts.php

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

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

Ihateit

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.

Ihateit

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.

fastestpc

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.

PRO

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; ?>

fastestpc

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