VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: faiqnaseem on November 24, 2012, 08:37:02 AM

Title: Virtumart Related Prroducts
Post by: faiqnaseem on November 24, 2012, 08:37:02 AM
how to display only thubnails of products in related products area,my current code is showing the link too i-e inage with href tittle of product name.I just want to show the thumbnails

<?php
foreach ($this->product->customfieldsRelatedProducts as $field) {
?>
?php echo $field->display ?>      
<?php } ?>

Title: Re: Virtumart Related Prroducts
Post by: bytelord on November 24, 2012, 17:09:29 PM
Hello,

This i think will not work with str_replace, you will use preg_replace to replace the string after img alt and before </a> ... so

$field->display = preg_replace('#(<img.*?>).*?(</a>)#', '$1$2', $field->display);

This will remove the <a> link text, so your code will look like:

<?php
foreach ($this->product->customfieldsRelatedProducts as $field
{
$field->display preg_replace('#(<img.*?>
).*?(</a>)#', '$1$2', $field->display);
echo $field->display;
}
?>


Please test it and let me know if is working for you

Regards
Title: Re: Virtumart Related Prroducts
Post by: faiqnaseem on November 30, 2012, 08:54:16 AM
there is php tag missing in the code,cant figure it out myself
Title: Re: Virtumart Related Prroducts
Post by: bytelord on November 30, 2012, 16:17:02 PM
Hello,

Is not missing ... may be from copy paste the editors throw it out ... i place a screenshot of the code ... Please check it

without tags also:

       $field->display = preg_replace('#(<img.*?>).*?(</a>)#', '$1$2', $field->display);


Regards



[attachment cleanup by admin]
Title: Re: Virtumart Related Prroducts
Post by: faiqnaseem on November 30, 2012, 20:44:26 PM
Thanks for your kind awesome help
Title: Re: Virtumart Related Prroducts
Post by: bytelord on November 30, 2012, 22:04:50 PM
You are welcome, good luck with your project