I need to display products in a list, like an excel table.
In each line a cell for a small image, another cell to the product name, etc., until the end of the row a button "buy" or "add to cart".
For me it is no important the product image, because it is medical testing.
The chances of virtuemart I know are always showing the product in a large space, a great shot, almost always square format.
Is there any chance of having the products in a list or table as excel? Maybe a theme that show the products in a simple list?
I hope you understand.
I'd love to hear about that too...
If this is not existing, maybe some people would like to join to share a mini-project for this. Not sure how complicated it is but as noting is changed in logic but just the presentation is done as list it should (hopefuly) not be a big deal for a good programmer...
I would participate if others join...
This morning I customized the view for categories to show in a table, I'll share what I did and hopefully you can use it as a base.
This is to replace all the text in components/com_virtuemart/views/category/tmpl/default.php
Make sure to backup your old file in case this does not work.
<?php
/**
*
* Show the products in a category
*
* @package VirtueMart
* @subpackage
* @author RolandD
* @author Max Milbers
* @todo add pagination
* @link http://www.virtuemart.net
* @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: default.php 6053 2012-06-05 12:36:21Z Milbo $
*/
//vmdebug('$this->category',$this->category);
vmdebug('$this->category '.$this->category->category_name);
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
JHTML::_( 'behavior.modal' );
/* javascript for list Slide
Only here for the order list
can be changed by the template maker
*/
$js = "
jQuery(document).ready(function () {
jQuery('.orderlistcontainer').hover(
function() { jQuery(this).find('.orderlist').stop().show()},
function() { jQuery(this).find('.orderlist').stop().hide()}
)
});
";
$document = JFactory::getDocument();
$document->addScriptDeclaration($js);
/*$edit_link = '';
if(!class_exists('Permissions')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'permissions.php');
if (Permissions::getInstance()->check("admin,storeadmin")) {
$edit_link = '<a href="'.JURI::root().'index.php?option=com_virtuemart&tmpl=component&view=category&task=edit&virtuemart_category_id='.$this->category->virtuemart_category_id.'">
'.JHTML::_('image', 'images/M_images/edit.png', JText::_('COM_VIRTUEMART_PRODUCT_FORM_EDIT_PRODUCT'), array('width' => 16, 'height' => 16, 'border' => 0)).'</a>';
}
echo $edit_link; */
if ( empty($this->keyword) ) {
?>
<div class="category_description">
<?php echo $this->category->category_description ; ?>
</div>
<?php
}
/* Show child categories */
if ( VmConfig::get('showCategory',1) and empty($this->keyword)) {
if ($this->category->haschildren) {
// Category and Columns Counter
$iCol = 1;
$iCategory = 1;
// Calculating Categories Per Row
$categories_per_row = VmConfig::get ( 'categories_per_row', 3 );
$category_cellwidth = ' width'.floor ( 100 / $categories_per_row );
// Separator
$verticalseparator = " vertical-separator";
?>
<div class="category-view">
<?php // Start the Output
if(!empty($this->category->children)){
foreach ( $this->category->children as $category ) {
// Show the horizontal seperator
if ($iCol == 1 && $iCategory > $categories_per_row) { ?>
<div class="horizontal-separator"></div>
<?php }
// this is an indicator wether a row needs to be opened or not
if ($iCol == 1) { ?>
<div class="row">
<?php }
// Show the vertical seperator
if ($iCategory == $categories_per_row or $iCategory % $categories_per_row == 0) {
$show_vertical_separator = ' ';
} else {
$show_vertical_separator = $verticalseparator;
}
// Category Link
$caturl = JRoute::_ ( 'index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $category->virtuemart_category_id );
// Show Category ?>
<div class="category floatleft<?php echo $category_cellwidth . $show_vertical_separator ?>">
<div class="spacer">
<h2>
<a href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>">
<?php echo $category->category_name ?>
<br />
<?php // if ($category->ids) {
echo $category->images[0]->displayMediaThumb("",false);
//} ?>
</a>
</h2>
</div>
</div>
<?php
$iCategory ++;
// Do we need to close the current row now?
if ($iCol == $categories_per_row) { ?>
<div class="clear"></div>
</div>
<?php
$iCol = 1;
} else {
$iCol ++;
}
}
}
// Do we need a final closing row tag?
if ($iCol != 1) { ?>
<div class="clear"></div>
</div>
<?php } ?>
</div>
<?php }
}
?>
<div class="browse-view">
<?php
if (!empty($this->keyword)) {
?>
<h3><?php echo $this->keyword; ?></h3>
<?php
} ?>
<?php if ($this->search !==null ) { ?>
<form action="<?php echo JRoute::_('index.php?option=com_virtuemart&view=category&limitstart=0&virtuemart_category_id='.$this->category->virtuemart_category_id ); ?>" method="get">
<!--BEGIN Search Box --><div class="virtuemart_search">
<?php echo $this->searchcustom ?>
<br />
<?php echo $this->searchcustomvalues ?>
<input name="keyword" class="inputbox" type="text" size="20" value="<?php echo $this->keyword ?>" />
<input type="submit" value="<?php echo JText::_('COM_VIRTUEMART_SEARCH') ?>" class="button" onclick="this.form.keyword.focus();"/>
</div>
<input type="hidden" name="search" value="true" />
<input type="hidden" name="view" value="category" />
</form>
<!-- End Search Box -->
<?php } ?>
<?php // Show child categories
if (!empty($this->products)) {
?>
<div class="orderby-displaynumber">
<div class="width70 floatleft">
<?php echo $this->orderByList['orderby']; ?>
</div>
<div class="width30 floatright display-number"><?php echo $this->vmPagination->getResultsCounter();?><br/><?php echo $this->vmPagination->getLimitBox(); ?></div>
<div class="vm-pagination">
<?php echo $this->vmPagination->getPagesLinks(); ?>
<span style="float:right"><?php echo $this->vmPagination->getPagesCounter(); ?></span>
</div>
<div class="clear"></div>
</div> <!-- end of orderby-displaynumber -->
<h1><?php echo $this->category->category_name; ?></h1>
<?php
// Category and Columns Counter
$iBrowseCol = 1;
$iBrowseProduct = 1;
// Calculating Products Per Row
$BrowseProducts_per_row = $this->perRow;
$Browsecellwidth = ' width'.floor ( 100 / $BrowseProducts_per_row );
// Separator
$verticalseparator = " vertical-separator";
// Count products
$BrowseTotalProducts = 0;
foreach ( $this->products as $product ) {
$BrowseTotalProducts ++;
}
?>
<table class="orders">
<tr>
<th>Name</th>
<th>Quantity</th>
<th>Price</th>
<th> Product Details </th>
<th> Add to Cart </th>
</tr>
<?php
// Start the Output
foreach ( $this->products as $product ) {
// Show the horizontal seperator
if ($iBrowseCol == 1 && $iBrowseProduct > $BrowseProducts_per_row) { ?>
<div class="horizontal-separator"></div>
<?php }
?>
<tr>
<td><?php echo JHTML::link($product->link, $product->product_name); ?></td>
<td><?php // Product Short Description
echo shopFunctionsF::limitStringByWord($product->product_s_desc, 40, '...') ?>
</td>
<td><?php echo $this->currency->createPriceDiv('basePrice','COM_VIRTUEMART_PRODUCT_BASEPRICE',$product->prices); ?> </td>
<td><?php // Product Details Button
echo JHTML::link($product->link, JText::_('COM_VIRTUEMART_PRODUCT_DETAILS'), array('title' => $product->product_name,'class' => 'product-details'));
?></td>
<td>
<form method="post" class="product" action="index.php" id="addtocartproduct<?php echo $product->virtuemart_product_id ?>">
<div class="addtocart-bar">
<?php echo $this->product->virtuemart_product_id;?>
<span class="quantity-box">
<input type="text" class="quantity-input" name="quantity[]" value="1" />
</span>
<span class="quantity-controls">
<input type="button" class="quantity-controls quantity-plus" />
<input type="button" class="quantity-controls quantity-minus" />
</span>
<?php // Display the quantity box END ?>
<?php // Add the button
$button_lbl = JText::_('COM_VIRTUEMART_CART_ADD_TO');
$button_cls = ''; //$button_cls = 'addtocart_button';
if (VmConfig::get('check_stock') == '1' && !$this->product->product_in_stock) {
$button_lbl = JText::_('COM_VIRTUEMART_CART_NOTIFY');
$button_cls = 'notify-button';
} ?>
<?php // Display the add to cart button ?>
<span class="addtocart-button">
<input type="submit" name="addtocart" class="addtocart-button" value="<?php echo $button_lbl ?>" title="<?php echo $button_lbl ?>" />
</span>
<div class="clear"></div>
</div>
<?php // Display the add to cart button END ?>
<input type="hidden" class="pname" value="<?php echo $product->product_name ?>">
<input type="hidden" name="option" value="com_virtuemart" />
<input type="hidden" name="view" value="cart" />
<noscript><input type="hidden" name="task" value="add" /></noscript>
<input type="hidden" name="virtuemart_product_id[]" value="<?php echo $product->virtuemart_product_id ?>" />
<?php /** @todo Handle the manufacturer view */ ?>
<input type="hidden" name="virtuemart_manufacturer_id" value="<?php echo $product->virtuemart_manufacturer_id ?>" />
<input type="hidden" name="virtuemart_category_id[]" value="<?php echo $product->virtuemart_category_id ?>" />
</form>
</td>
</tr>
<?php }
} // end of foreach ( $this->products as $product )
?>
</table></div><!-- end browse-view -->
Great!!
Thanks for sharing!
Bernhard
@e-learningstudios: Thanks for the code ... it worked like a charm. Would you know of a way to include custom fields in the list?
your code to me and was very helpful, thanks!
can I ask you how to
- add the column amount discount,
- change the order of columns,
- and add the image of the product as in the shopping cart.
thanks anyway
I'm trying to use this on 1.1.9 and it gives me an internal server error. Is there anything specific I need to do in order to make this work ? If you guys cant help I will have to pay somebody to make this work.
Thanks
aykun, VM1.1.9 is no longer supported. http://forum.virtuemart.net/index.php?topic=106866.0
Hello all,
First of all thank you for this seemingly wonderfull script..
But probably because my lack of skills I can't get it to work..
I tried to change the default.php file like you described above, but it doesn't seem to have any effect om my website..
(check http://kunstvoorkunst.com/index.php/bestellen/patat (http://kunstvoorkunst.com/index.php/bestellen/patat) for example)
Do I need to change settings in vm as well?
- by the way, I'm running Joomla 2.5.8 and VM2 -
Could someone post a link where the code supplied by e-learning is used? Curious to see how it lays out.
Thanks e-learningstudios!! Your post saved me hours of trying to do the same thing. I simply copied your code and used it to replace mine and it works perfectly! Just wanted to point out to anyone reading this that you should not replace the file components/com_virtuemart/views/category/tmpl/default.php - instead create a new one in your template, for example: templates/(template name)/html/com_virtuemart/category/default.php
i tried the code but i'm getting a "Parse error: syntax error, unexpected '}' in /components/com_virtuemart/views/category/tmpl/default.php on line 1"
i checked the code but i found nothing wrong.
I'm running on a joomla 2.5.14 and vm 2.0.24
would really appreciate for any quick response
Use php highlighting in Notepad++ for rechecking syntax.
Quote from: e-learningstudios on August 03, 2012, 14:46:40 PM
This morning I customized the view for categories to show in a table, I'll share what I did and hopefully you can use it as a base.
This is to replace all the text in components/com_virtuemart/views/category/tmpl/default.php
Make sure to backup your old file in case this does not work.
<?php
/**
*
* Show the products in a category
*
* @package VirtueMart
* @subpackage
* @author RolandD
* @author Max Milbers
* @todo add pagination
* @link http://www.virtuemart.net
* @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: default.php 6053 2012-06-05 12:36:21Z Milbo $
*/
//vmdebug('$this->category',$this->category);
vmdebug('$this->category '.$this->category->category_name);
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
JHTML::_( 'behavior.modal' );
/* javascript for list Slide
Only here for the order list
can be changed by the template maker
*/
$js = "
jQuery(document).ready(function () {
jQuery('.orderlistcontainer').hover(
function() { jQuery(this).find('.orderlist').stop().show()},
function() { jQuery(this).find('.orderlist').stop().hide()}
)
});
";
$document = JFactory::getDocument();
$document->addScriptDeclaration($js);
/*$edit_link = '';
if(!class_exists('Permissions')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'permissions.php');
if (Permissions::getInstance()->check("admin,storeadmin")) {
$edit_link = '<a href="'.JURI::root().'index.php?option=com_virtuemart&tmpl=component&view=category&task=edit&virtuemart_category_id='.$this->category->virtuemart_category_id.'">
'.JHTML::_('image', 'images/M_images/edit.png', JText::_('COM_VIRTUEMART_PRODUCT_FORM_EDIT_PRODUCT'), array('width' => 16, 'height' => 16, 'border' => 0)).'</a>';
}
echo $edit_link; */
if ( empty($this->keyword) ) {
?>
<div class="category_description">
<?php echo $this->category->category_description ; ?>
</div>
<?php
}
/* Show child categories */
if ( VmConfig::get('showCategory',1) and empty($this->keyword)) {
if ($this->category->haschildren) {
// Category and Columns Counter
$iCol = 1;
$iCategory = 1;
// Calculating Categories Per Row
$categories_per_row = VmConfig::get ( 'categories_per_row', 3 );
$category_cellwidth = ' width'.floor ( 100 / $categories_per_row );
// Separator
$verticalseparator = " vertical-separator";
?>
<div class="category-view">
<?php // Start the Output
if(!empty($this->category->children)){
foreach ( $this->category->children as $category ) {
// Show the horizontal seperator
if ($iCol == 1 && $iCategory > $categories_per_row) { ?>
<div class="horizontal-separator"></div>
<?php }
// this is an indicator wether a row needs to be opened or not
if ($iCol == 1) { ?>
<div class="row">
<?php }
// Show the vertical seperator
if ($iCategory == $categories_per_row or $iCategory % $categories_per_row == 0) {
$show_vertical_separator = ' ';
} else {
$show_vertical_separator = $verticalseparator;
}
// Category Link
$caturl = JRoute::_ ( 'index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $category->virtuemart_category_id );
// Show Category ?>
<div class="category floatleft<?php echo $category_cellwidth . $show_vertical_separator ?>">
<div class="spacer">
<h2>
<a href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>">
<?php echo $category->category_name ?>
<br />
<?php // if ($category->ids) {
echo $category->images[0]->displayMediaThumb("",false);
//} ?>
</a>
</h2>
</div>
</div>
<?php
$iCategory ++;
// Do we need to close the current row now?
if ($iCol == $categories_per_row) { ?>
<div class="clear"></div>
</div>
<?php
$iCol = 1;
} else {
$iCol ++;
}
}
}
// Do we need a final closing row tag?
if ($iCol != 1) { ?>
<div class="clear"></div>
</div>
<?php } ?>
</div>
<?php }
}
?>
<div class="browse-view">
<?php
if (!empty($this->keyword)) {
?>
<h3><?php echo $this->keyword; ?></h3>
<?php
} ?>
<?php if ($this->search !==null ) { ?>
<form action="<?php echo JRoute::_('index.php?option=com_virtuemart&view=category&limitstart=0&virtuemart_category_id='.$this->category->virtuemart_category_id ); ?>" method="get">
<!--BEGIN Search Box --><div class="virtuemart_search">
<?php echo $this->searchcustom ?>
<br />
<?php echo $this->searchcustomvalues ?>
<input name="keyword" class="inputbox" type="text" size="20" value="<?php echo $this->keyword ?>" />
<input type="submit" value="<?php echo JText::_('COM_VIRTUEMART_SEARCH') ?>" class="button" onclick="this.form.keyword.focus();"/>
</div>
<input type="hidden" name="search" value="true" />
<input type="hidden" name="view" value="category" />
</form>
<!-- End Search Box -->
<?php } ?>
<?php // Show child categories
if (!empty($this->products)) {
?>
<div class="orderby-displaynumber">
<div class="width70 floatleft">
<?php echo $this->orderByList['orderby']; ?>
</div>
<div class="width30 floatright display-number"><?php echo $this->vmPagination->getResultsCounter();?><br/><?php echo $this->vmPagination->getLimitBox(); ?></div>
<div class="vm-pagination">
<?php echo $this->vmPagination->getPagesLinks(); ?>
<span style="float:right"><?php echo $this->vmPagination->getPagesCounter(); ?></span>
</div>
<div class="clear"></div>
</div> <!-- end of orderby-displaynumber -->
<h1><?php echo $this->category->category_name; ?></h1>
<?php
// Category and Columns Counter
$iBrowseCol = 1;
$iBrowseProduct = 1;
// Calculating Products Per Row
$BrowseProducts_per_row = $this->perRow;
$Browsecellwidth = ' width'.floor ( 100 / $BrowseProducts_per_row );
// Separator
$verticalseparator = " vertical-separator";
// Count products
$BrowseTotalProducts = 0;
foreach ( $this->products as $product ) {
$BrowseTotalProducts ++;
}
?>
<table class="orders">
<tr>
<th>Name</th>
<th>Quantity</th>
<th>Price</th>
<th> Product Details </th>
<th> Add to Cart </th>
</tr>
<?php
// Start the Output
foreach ( $this->products as $product ) {
// Show the horizontal seperator
if ($iBrowseCol == 1 && $iBrowseProduct > $BrowseProducts_per_row) { ?>
<div class="horizontal-separator"></div>
<?php }
?>
<tr>
<td><?php echo JHTML::link($product->link, $product->product_name); ?></td>
<td><?php // Product Short Description
echo shopFunctionsF::limitStringByWord($product->product_s_desc, 40, '...') ?>
</td>
<td><?php echo $this->currency->createPriceDiv('basePrice','COM_VIRTUEMART_PRODUCT_BASEPRICE',$product->prices); ?> </td>
<td><?php // Product Details Button
echo JHTML::link($product->link, JText::_('COM_VIRTUEMART_PRODUCT_DETAILS'), array('title' => $product->product_name,'class' => 'product-details'));
?></td>
<td>
<form method="post" class="product" action="index.php" id="addtocartproduct<?php echo $product->virtuemart_product_id ?>">
<div class="addtocart-bar">
<?php echo $this->product->virtuemart_product_id;?>
<span class="quantity-box">
<input type="text" class="quantity-input" name="quantity[]" value="1" />
</span>
<span class="quantity-controls">
<input type="button" class="quantity-controls quantity-plus" />
<input type="button" class="quantity-controls quantity-minus" />
</span>
<?php // Display the quantity box END ?>
<?php // Add the button
$button_lbl = JText::_('COM_VIRTUEMART_CART_ADD_TO');
$button_cls = ''; //$button_cls = 'addtocart_button';
if (VmConfig::get('check_stock') == '1' && !$this->product->product_in_stock) {
$button_lbl = JText::_('COM_VIRTUEMART_CART_NOTIFY');
$button_cls = 'notify-button';
} ?>
<?php // Display the add to cart button ?>
<span class="addtocart-button">
<input type="submit" name="addtocart" class="addtocart-button" value="<?php echo $button_lbl ?>" title="<?php echo $button_lbl ?>" />
</span>
<div class="clear"></div>
</div>
<?php // Display the add to cart button END ?>
<input type="hidden" class="pname" value="<?php echo $product->product_name ?>">
<input type="hidden" name="option" value="com_virtuemart" />
<input type="hidden" name="view" value="cart" />
<noscript><input type="hidden" name="task" value="add" /></noscript>
<input type="hidden" name="virtuemart_product_id[]" value="<?php echo $product->virtuemart_product_id ?>" />
<?php /** @todo Handle the manufacturer view */ ?>
<input type="hidden" name="virtuemart_manufacturer_id" value="<?php echo $product->virtuemart_manufacturer_id ?>" />
<input type="hidden" name="virtuemart_category_id[]" value="<?php echo $product->virtuemart_category_id ?>" />
</form>
</td>
</tr>
<?php }
} // end of foreach ( $this->products as $product )
?>
</table></div><!-- end browse-view -->
Useful information shared. I am very happy to read this article. Thanks
Thanks omanhi. Great work!
I tried that on http://street-takeaway.ch/index.php/pizza , but it doesnt show the Price for a Product. Can you help me out?
Are the colum widths adjustable?
Cheers
Maybe search on forum a bit?
https://forum.virtuemart.net/index.php?topic=110364.msg342648#new
https://forum.virtuemart.net/index.php?topic=111340.msg342648#new
https://forum.virtuemart.net/index.php?topic=97132.msg345360
http://forum.virtuemart.net/index.php?topic=106119.msg357622#new
Dear Maxim
i saw a lot of your replies. Most of them are not helpful and you are disturbing Virtuemart users. You are like a Stone on the road, that will get bigger and bigger.
Please help users, i also help users. Do not throw Stones on my way.
Cheers
turkish74 abuse of anyone in this forum is not acceptable, especially when this is aimed at someone who helps so many users.
You say "i also help others" yet all the posts from you have been to ask questions.
Thank you. That's what I looking for. but if I want to show this product list in categories page and include product attribute. Is it possible? please help.
any way to get the add to cart smaller. Leaves a large inter line gap.