Hi,
I'm using redVMProductfinder to have a better search form in my shop. Since this component doesn't use the flypage and the browse page that is configured in VM I had to change the template of the result page from the component. I succeeded for 90% but the last step is to add the 'Add to cart' box next to every result. In the template I use in VM I just had to add 'echo $form_addtocart;' to get this working but when I try this in the template of the component, nothing happens.
I guess this is because the variable '$form_addtocart' is empty (or not known) in this template.
So the question is... What do I have to do to be able to use 'echo $form_addtocart;' in the template? Do I have to include something? Do I have to copy lines of code?
This is the code in the results page:
<?php
/**
* @copyright Copyright (C) 2008-2009 redCOMPONENT.com. All rights reserved.
* @license can be read in this package of software in the file license.txt or
* read on http://redcomponent.com/license.txt
* Developed by email@recomponent.com - redCOMPONENT.com
*/
defined('_JEXEC') or die('Restricted access');
$config = JComponentHelper::getParams('com_redvmproductfinder');
echo JText::_('SEARCH_RESULTS')."(".count($this->searchresult['products']).")";
if (count($this->searchresult) > 0) {
foreach ($this->searchresult['scores'] as $assoc_id => $score) {
if (array_key_exists($assoc_id, $this->searchresult['products'])) {
?>
<?php
$product_name = $this->searchresult['products'][$assoc_id]->product_name;
// Ik heb in product_desc meerdere gegevens gestopt gescheiden door µ
$allFields = explode("µ", $this->searchresult['products'][$assoc_id]->product_desc);
$Domaine = substr($allFields[1], 0, strlen($allFields[1]) - 1);
$Appelation = substr($allFields[4], 0, strlen($allFields[4]) - 1);
$Millesime = substr($allFields[3], 0, strlen($allFields[3]) - 1);
$Couleur = substr($allFields[2], 0, strlen($allFields[2]) - 1);
$Ref = substr($allFields[5], 0, strlen($allFields[5]) - 1);
$Stock = substr($allFields[6], 0, strlen($allFields[6]) - 1);
?>
<div class="productfinder_product">
<div style="width: 100%; border-bottom: 1px outset #000000"> <!-- Main Div -->
<div style="float: left; width: 100%; height: 25px; padding-top: 5px"> <!-- Product Name -->
<a style="font-size:18px; font-weight:bold;" href="<?php echo JRoute::_('index.php?option=com_virtuemart&product_id='.$this->searchresult['products'][$assoc_id]->product_id.'&page=shop.product_details');?>"><?php echo $product_name ?></a>
</div> <!-- End of Product Name -->
<div style="float: left; width: 15%; height: 100px; padding-bottom: 5px"> <!-- Thumbnail -->
<a href="<?php echo JRoute::_('index.php?option=com_virtuemart&product_id='.$this->searchresult['products'][$assoc_id]->product_id.'&page=shop.product_details');?>">
<img src="<?php echo JURI::root().'components/com_virtuemart/shop_image/product/'.$this->searchresult['products'][$assoc_id]->product_thumb_image; ?>" alt="<?php echo $this->searchresult['products'][$assoc_id]->product_name; ?>" title="<?php echo $this->searchresult['products'][$assoc_id]->product_name; ?>"/>
</a>
</div> <!-- End of Thumbnail -->
<div style="float: left; width: 35%"> <!-- Properties -->
<div style="height: 25px; color: #961414">
<?php echo $Domaine ?>
</div>
<div style="height: 25px; color: #961414">
<?php echo $Appelation ?>
</div>
<div style="height: 25px; color: #961414">
<?php echo $Millesime ?>
</div>
<div style="height: 25px; color: #961414">
<?php echo $Couleur ?>
</div>
</div> <!-- End of Properties -->
<div style="float: left; width: 20%"> <!-- Reference and Stock -->
<div style="height: 50px; color: #961414">
<?php echo "Ref: ".$Ref ?>
</div>
<div style="height: 50px; color: #961414">
<?php
if ($this->searchresult['products'][$assoc_id]->product_in_stock >0)
{
$Amount = " (".$this->searchresult['products'][$assoc_id]->product_in_stock.")";
}
else
{
$Amount = "";
}
echo $Stock.$Amount;
?>
</div>
</div> <!-- End of Reference and Stock -->
<div style="float: left; width: 25%"> <!-- Sub Price and Cart -->
<div style="height: 40px; color: #961414" align="right"> <!-- Price -->
<font size="4" align="right">
<b>
<i>
<?php
$product_price = $this->searchresult['products'][$assoc_id]->product_price ;
echo "€".number_format($product_price,2);
?>
</i>
</b>
</font>
</div>
<div style="height: 60px"> <!-- Cart -->
<?php
echo $form_addtocart;
?>
</div>
</div> <!-- End of Price and Cart -->
</div> <!-- End of Main Div -->
<div style="clear:left;" class=hr><hr /></div>
</div>
<?php }
}
}
else { ?>
<div class="productfinder_product">
<?php echo JText::_('NO_PRODUCTS_FOUND'); ?>
<div style="clear:left;" class=hr><hr /></div>
</div>
<?php }
$returnurl = JRequest::getVar('returnurl', false);
if ($returnurl) $submiturl = JRoute::_(urldecode($returnurl));
else $submiturl = JRoute::_('index.php');
?>
<form name="adminForm" method="post" action="<?php echo $submiturl; ?>">
<?php if (!$returnurl) { ?>
<input type="hidden" name="option" value="com_redvmproductfinder" />
<input type="hidden" name="task" value="redvmproductfinder" />
<input type="hidden" name="controller" value="redvmproductfinder" />
<?php
}
$post = JRequest::get('request');
/* Create a link to get back to this result */
$geturl = 'index.php?option=com_redvmproductfinder&task=findproducts&view=redvmproductfinder&layout=redvmproductfinder&Itemid='.JRequest::getInt('Itemid');
foreach ($post as $key => $value) {
if (stripos($key, 'type') !== false) {
if (is_array($value)) {
foreach ($value as $vkey => $vvalue) {
$geturl .= '&'.$key.'[]='.$vvalue;
?>
<input type="hidden" name="<?php echo $key; ?>[]" value="<?php echo $vvalue; ?>" />
<?php }
}
else {
$geturl .= '&'.$key.'='.$value;
?>
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>" />
<?php }
}
}
?>
<div id="link_search"><input type="submit" name="submit" value="<?php echo JText::_('SEARCH_AGAIN'); ?>" /></div>
<div id="link_result"><?php echo JHTML::_('link', JRoute::_($geturl), JText::_('LINK_THIS_RESULT')); ?></div>
<?php
if ($returnurl) {
?>
<div id="link_returnurl"><?php echo JHTML::_('link', urldecode($returnurl), JText::_('LINK_RETURN')); ?></div>
<?php
}
?>
</form>
Tx.
Jan.