News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Modified Manufacturers Module with option to choose what the link of results is

Started by bardius, December 22, 2011, 15:18:06 PM

Previous topic - Next topic

bardius

If you want, like me, to have a module that presents the available manufacturers and be able to choose where the link of each goes you can try a small hack to the original manufacturer module.

At the modules\mod_virtuemart_manufacturer\mod_virtuemart_manufacturer.xml add another parameter

<param name="pointing_url" type="list" default="list"
      label="MOD_VIRTUEMART_MANUFACTURER_LINK_POINTING"
      description="MOD_VIRTUEMART_MANUFACTURER_LINK_POINTING_DESC">
      <option value="all">MOD_VIRTUEMART_MANUFACTURER_ALL</option>
      <option value="email">MOD_VIRTUEMART_MANUFACTURER_EMAIL</option>
      <option value="website">MOD_VIRTUEMART_MANUFACTURER_WEBSITE</option>
      <option value="products">MOD_VIRTUEMART_MANUFACTURER_PRODUCTS</option>
</param>

So you can be able to choose what you want to link on the results.

Afterwards edit the template file at modules\mod_virtuemart_manufacturer\tmpl\default.php and modify the $link code part under both "foreach ($manufacturers as $manufacturer) {"

//George BARDIS adding option for pointing link url
if($pointing_url == "all")
{
   $link = JROUTE::_('index.php?option=com_virtuemart&view=manufacturer&virtuemart_manufacturer_id=' . $manufacturer->virtuemart_manufacturer_id);
   $link_target = '_self';
   $link_title = $manufacturer->mf_name;
}
else if($pointing_url == "email")
{
   $link = 'mailto:' . $manufacturer->mf_email;
   $link_target = '_blank';
   $link_title = JText::_('COM_VIRTUEMART_EMAIL') . ' ' . $manufacturer->mf_name;
}
else if ($pointing_url == "website")
{
   $link = $manufacturer->mf_url;
   $link_target = '_blank';
   $link_title = JText::_('COM_VIRTUEMART_MANUFACTURER_PAGE') . ' ' . $manufacturer->mf_name;         
}
else if ($pointing_url == "products")
{
   $link = JROUTE::_('index.php?option=com_virtuemart&view=category&virtuemart_manufacturer_id=' . $manufacturer->virtuemart_manufacturer_id);
   $link_target = '_self';
   $link_title = JText::sprintf('COM_VIRTUEMART_PRODUCT_FROM_MF',$manufacturer->mf_name);         
}

?>
<div style="float:left;">
   <a href="<?php echo $link; ?>" title="<?php echo $link_title; ?>" target="<?php echo $link_target; ?>">
<?php //Bardis ENDS ?>

Now you are able to control where you link when someone clicks on the manufacturer item :)

Hope that you will find that useful
George Bardis
Team Leader / Senior Web Developer
http://www.bardis.info

vasiljevski

Great idea and a solution :) Thanks!

You just forgot to mention that:

$pointing_url=$params->get( 'pointing_url', 'all');

should be added to "modules\mod_virtuemart_manufacturer\mod_virtuemart_manufacturer.php"  for this to work :)