Hello,
In the Category Listing I see all categories (this is ok), but I see under the categories the products too. How can I make if I want to see only the categories, without products? I want to see the products only when I click the category.
The site isn´t online to gib you an URL, but I made a screenshot.
Thanks!
piru
[attachment cleanup by admin]
I don't think that its possible.
The category links are there to return products. If you don't want that you can remove the products from these categories
I think you don´t understand what I want (sorry for my english). Obviously I want to see the products when I click the category (the products from the category), but in this view I´m not in any category, I see only wich categories I have, and I can click in whichone I want to go.
I´m in Home - Products, why muss I see the products, the in the category are?
I want to see them only if I´m in Home - Products - Hunting Items
What kind of page/view is this?
\components\com_viertuemart\views\category\tmpl\default.php
sorry, I think is \components\com_viertuemart\views\categories\tmpl\default.php
Go to the VM configuration->Templates and check the Hope Page settings
I made it before, look how the settongs are in the screenshot, I think there is nothing more to do there...
[attachment cleanup by admin]
Now is the site online, I can give you a link to see what I mean: http://k-urz.de/v4c (http://k-urz.de/v4c)
In the first post I made a screenshot, to show what I don´t want so see.
I just fixed this problem with a dirty trick.
components\com_virtuemart\views\category\tmpl\default.php
Line 32 after: jQuery(document).ready(function () {
this
if(jQuery('div.category-view').length>0) jQuery('div.browse-view').hide();
Hi,
I'm sorry that I have to say, but it's really horrible solution.
1) If you do not need a some code, so do not generate it => slower loading pages
2) Hiding using javascript is a bad habit =>
2a) if the page or the client PC will be slow, so the block disappears after the page is loaded (it will be seen)
2b) if a user has javascript disabled in browser or there is a javascript error, so a remaining javascript code is not executed (your block remains visible)
You can use this PHP condition in the view:
.....
<?php if (empty($this->category->haschildren)) { ?>
<div class="browse-view">
......
......
......
</div><!-- end browse-view -->
<? } ?>
Regards,
Pavel
PS:I have not tested it, but it's not complicated, so I suppose it will work;-)
Hi Pavel,
Quote from: byPV on April 24, 2014, 19:56:55 PM
I'm sorry that I have to say, but it's really horrible solution.
Quote from: piru on April 24, 2014, 14:22:23 PM
I just fixed this problem with a dirty trick.
;)
I didn´t get a solution before, beause of thi I had to do something.
But now I did it with your solution, it works perfectly!!
Thanks :D
Regards piru
I just find a problem with your solution, the search doesn´t work more.
If I try to find something: No result
I have to make again mine horrible solution... :(
Regards piru
Hi,
change the condition to:
<?php if (empty($this->category->haschildren) || !empty($this->keyword)) { ?>
Regads,
Pavel
now works perfectly,
thanks Pavel! :)
Cheers piru
Hi,
I updated Virtuemart to 2.6.6 (I had an old version, I don´t know more which one).
I made the changes in the file components\com_virtuemart\views\category\tmpl\default.php again, but now, I don´t see the images and category name not more. The problem ist not this changes, because I change the file with the original and I don´t see the categories either.
Hier 2 images, one how I saw this before the update (right: categories.jpg), and how I see this now after the update (wrong: categories_2.jpg).
If this help, hier the code from the file:
<?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 6556 2012-10-17 18:15:30Z kkmediaproduction $
*/
//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);
if (empty($this->keyword) and !empty($this->category)) {
?>
<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 (!empty($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, FALSE);
// 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
}
}
?>
<?php if (empty($this->category->haschildren) || !empty($this->keyword)) { ?>
<div class="browse-view">
<?php
if (!empty($this->keyword)) {
?>
<h3><?php echo $this->keyword; ?></h3>
<?php
} ?>
<?php if (!empty($this->keyword)) {
$category_id = JRequest::getInt ('virtuemart_category_id', 0); ?>
<form action="<?php echo JRoute::_ ('index.php?option=com_virtuemart&view=category&limitstart=0', FALSE); ?>" 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"/>
<input type="hidden" name="option" value="com_virtuemart"/>
<input type="hidden" name="virtuemart_category_id" value="<?php echo $category_id; ?>"/>
</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']; ?>
<?php echo $this->orderByList['manufacturer']; ?>
</div>
<div class="width30 floatright display-number"><?php echo $this->vmPagination->getResultsCounter ();?><br/><?php echo $this->vmPagination->getLimitBox ($this->category->limit_list_step); ?></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";
$BrowseTotalProducts = count($this->products);
// 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
}
// this is an indicator wether a row needs to be opened or not
if ($iBrowseCol == 1) {
?>
<div class="row">
<?php
}
// Show the vertical seperator
if ($iBrowseProduct == $BrowseProducts_per_row or $iBrowseProduct % $BrowseProducts_per_row == 0) {
$show_vertical_separator = ' ';
} else {
$show_vertical_separator = $verticalseparator;
}
// Show Products
?>
<div class="product floatleft<?php echo $Browsecellwidth . $show_vertical_separator ?>">
<div class="spacer">
<div class="width100 floatleft center">
<a title="<?php echo $product->product_name ?>" href="<?php echo $product->link; ?>">
<?php
echo $product->images[0]->displayMediaThumb('class="browseProductImage"', false);
?>
</a>
<!-- The "Average Customer Rating" Part -->
<?php // Output: Average Product Rating
if ($this->showRating) {
$maxrating = VmConfig::get('vm_maximum_rating_scale', 5);
if (empty($product->rating)) {
?>
<span class="vote"><?php echo JText::_('COM_VIRTUEMART_RATING') . ' ' . JText::_('COM_VIRTUEMART_UNRATED') ?></span>
<?php
} else {
$ratingwidth = $product->rating * 12; //I don't use round as percetntage with works perfect, as for me
?>
<span class="vote">
<?php echo JText::_('COM_VIRTUEMART_RATING') . ' ' . round($product->rating) . '/' . $maxrating; ?><br/>
<span title=" <?php echo (JText::_("COM_VIRTUEMART_RATING_TITLE") . round($product->rating) . '/' . $maxrating) ?>" class="category-ratingbox" style="display:inline-block;">
<span class="stars-orange" style="width:<?php echo $ratingwidth.'px'; ?>">
</span>
</span>
</span>
<?php
}
}
if ( VmConfig::get ('display_stock', 1)) { ?>
<!-- if (!VmConfig::get('use_as_catalog') and !(VmConfig::get('stockhandle','none')=='none')){?> -->
<div class="paddingtop8">
<span class="vmicon vm2-<?php echo $product->stock->stock_level ?>" title="<?php echo $product->stock->stock_tip ?>"></span>
<span class="stock-level"><?php echo JText::_ ('COM_VIRTUEMART_STOCK_LEVEL_DISPLAY_TITLE_TIP') ?></span>
</div>
<?php } ?>
</div>
<div class="width70 floatright">
<h2><?php echo JHTML::link ($product->link, $product->product_name).' - '.$product->product_sku; ?></h2>
<?php // Product Short Description
if (!empty($product->product_s_desc)) {
?>
<p class="product_s_desc">
<?php echo shopFunctionsF::limitStringByWord ($product->product_s_desc, 40, '...') ?>
</p>
<?php } ?>
<div class="product-price marginbottom12" id="productPrice<?php echo $product->virtuemart_product_id ?>">
<?php
if ($this->show_prices == '1') {
if ($product->prices['salesPrice']<=0 and VmConfig::get ('askprice', 1) and !$product->images[0]->file_is_downloadable) {
echo JText::_ ('COM_VIRTUEMART_PRODUCT_ASKPRICE');
}
//todo add config settings
if ($this->showBasePrice) {
echo $this->currency->createPriceDiv ('basePrice', 'COM_VIRTUEMART_PRODUCT_BASEPRICE', $product->prices);
echo $this->currency->createPriceDiv ('basePriceVariant', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_VARIANT', $product->prices);
}
echo $this->currency->createPriceDiv ('variantModification', 'COM_VIRTUEMART_PRODUCT_VARIANT_MOD', $product->prices);
if (round($product->prices['basePriceWithTax'],$this->currency->_priceConfig['salesPrice'][1]) != $product->prices['salesPrice']) {
echo '<div class="price-crossed" >' . $this->currency->createPriceDiv ('basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $product->prices) . "</div>";
}
if (round($product->prices['salesPriceWithDiscount'],$this->currency->_priceConfig['salesPrice'][1]) != $product->prices['salesPrice']) {
echo $this->currency->createPriceDiv ('salesPriceWithDiscount', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITH_DISCOUNT', $product->prices);
}
echo $this->currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $product->prices);
if ($product->prices['discountedPriceWithoutTax'] != $product->prices['priceWithoutTax']) {
echo $this->currency->createPriceDiv ('discountedPriceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $product->prices);
} else {
echo $this->currency->createPriceDiv ('priceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $product->prices);
}
echo $this->currency->createPriceDiv ('discountAmount', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT', $product->prices);
echo $this->currency->createPriceDiv ('taxAmount', 'COM_VIRTUEMART_PRODUCT_TAX_AMOUNT', $product->prices);
$unitPriceDescription = JText::sprintf ('COM_VIRTUEMART_PRODUCT_UNITPRICE', $product->product_unit);
echo $this->currency->createPriceDiv ('unitPrice', $unitPriceDescription, $product->prices);
} ?>
</div>
<p>
<?php // Product Details Button
echo JHTML::link ($product->link, JText::_ ('COM_VIRTUEMART_PRODUCT_DETAILS'), array('title' => $product->product_name, 'class' => 'product-details'));
?>
</p>
</div>
<div class="clear"></div>
</div>
<!-- end of spacer -->
</div> <!-- end of product -->
<?php
// Do we need to close the current row now?
if ($iBrowseCol == $BrowseProducts_per_row || $iBrowseProduct == $BrowseTotalProducts) {
?>
<div class="clear"></div>
</div> <!-- end of row -->
<?php
$iBrowseCol = 1;
} else {
$iBrowseCol++;
}
$iBrowseProduct++;
} // end of foreach ( $this->products as $product )
// Do we need a final closing row tag?
if ($iBrowseCol != 1) {
?>
<div class="clear"></div>
<?php
}
?>
<div class="vm-pagination"><?php echo $this->vmPagination->getPagesLinks (); ?><span style="float:right"><?php echo $this->vmPagination->getPagesCounter (); ?></span></div>
<?php
} elseif (!empty($this->keyword)) {
echo JText::_ ('COM_VIRTUEMART_NO_RESULT') . ($this->keyword ? ' : (' . $this->keyword . ')' : '');
}
?>
</div><!-- end browse-view -->
<? } ?>
If you want to see the site: http://k-urz.de/vd7
Greats
piru
[attachment cleanup by admin]
Hi,
this is weird. It seems that VirtueMart found no children in the category. Please, check the hierarchy of categories (in admin), if everything is ok.
Pavel
Hi Pavel,
in Admin is all right (you can see the image). You can see at the site the categories at the left side, and you can clic in the category and see the products...
piru
[attachment cleanup by admin]
Hi piru,
I probably found the problem and I even found that hack in the template that you use to hide the products is completely unnecessary ;-)... Before, I did not notice that there is a special layout for this :-/...
In VirtueMart 2.6 was changed the code for loading subcategories. In this version is not possible show subcategories in the Top Level Category if you have not set category layout "categories". Category layout can be set in the VM configuration (tab Templates -> field: Category Layout), or in a category (field: Category Browse Page) or in the Menu Item (field: Page Layout). This new condition is weird and maybe it's a bug.
However, what is definitely a bug that this does not work if category layout is set in the menu item (you just need this). I have fix for this. It is necessary to move a few lines of code...
/components/com_virtuemart/views/category/view.html.php
FROM
225 $menus = $app->getMenu();
. $menu = $menus->getActive();
. if(!empty($menu->query['categorylayout']) and $menu->query['virtuemart_category_id']==$categoryId){
. $category->category_layout = $menu->query['categorylayout'];
229 }
TO
91 if($categoryId!==-1){
. $vendorId = 1;
. $category = $categoryModel->getCategory($categoryId);
.
. // Insert here
. $menus = $app->getMenu();
. $menu = $menus->getActive();
. if(!empty($menu->query['categorylayout']) and $menu->query['virtuemart_category_id']==$categoryId){
. $category->category_layout = $menu->query['categorylayout'];
. }
101 }
Now, if you set category layout in menu item for your Products link to "categories" you don't need anymore hack from previous posts in this thread.
Pavel
Hi Pavel,
I didn´t understand a thing, I have to change a code, doesn´t matter which option I choose?
Or if I make Menu Item (field: Page Layout) I have not to change the code?.
I tested the other 2 options but without change a code (I didn´t do it) I see the categories but without products. I want to try the option Menu Item (field: Page Layout), but I don´t know wo I can find this... sorry. Wichone is Menu Item?
Thanks!
piru
I just find what you mind with Menu Item (field: Page Layout), I tried but there is no change.
I think I have to change the code... I will try
You need to set the layout for the category Top Level Category and it can be set in two ways:
Option 1) In VM configuration set globally "Category Layout" to "categories". And in each category, set the "Category Browse Page" to "default". Annoying, but it will probably work ;-).
Option 2) Set the "Page Layout" in the Menu Item, but there is a bug and must be fixed as I wrote in the previous post.
P.
I did the Option 2) and it works, thanks!!!
Best regards
piru
I had to change again "Page Layout" in the Menu Item to default, because with "Page Layout" in the Menu Item --> categories, doesn´t work the search... :-[
OMG, I forgot about this. This is terrible. One bug fixed and more will appear :-(. In this case, the only option is probably to load the categories in the template.
I'll write the code for it.
should I upload again the original code from /components/com_virtuemart/views/category/view.html.php?
Thank you so much for all. Maybe I will no make today more changes because I have to work only 20 minutes more ;)
oiru
ad Original file)
It is up to you. I believe that the fix is correct, but you do not need it now ;-).
P.
wich fix?
Ok, here's the code for load categories.
Insert the following lines (between FIX BEGIN and FIX END) into the layout "components\com_virtuemart\views\category\tmpl\default.php" at the beginning of the file:
...
...
...
$js = "
jQuery(document).ready(function () {
jQuery('.orderlistcontainer').hover(
function() { jQuery(this).find('.orderlist').stop().show()},
function() { jQuery(this).find('.orderlist').stop().hide()}
)
});
";
// FIX BEGIN: Load the categories in Top Level Category
if (!empty($this->category) && $this->category->virtuemart_category_id == 0 && empty($this->category->children))
{
$categoryModel = VmModel::getModel('category');
$this->category->children = $categoryModel->getChildCategoryList(1, $this->category->virtuemart_category_id, $categoryModel->getDefaultOrdering(), $categoryModel->_selectedOrderingDir);
$this->category->haschildren = !empty($this->category->children);
$categoryModel->addImages($this->category->children, 1);
}
// FIX END
$document = JFactory::getDocument ();
$document->addScriptDeclaration ($js);
...
...
...
Remember to include a condition to hide the products again.
ad Fix for Menu Item)
This was fix for bug with Page Layout which VM ignores, but if you don't use it, so you don't need it. You can revert to original script safely.
P.
I will make this tomorrow, I have to go now.
But I have to ask you:
I will change the code between FIX BEGIN and FIX END (understood)
But this I didn´t understand:
QuoteRemember to include a condition to hide the products again.
ad Fix for Menu Item)
This was fix for bug with Page Layout which VM ignores, but if you don't use it, so you don't need it. You can revert to original script safely.
thanks
piru
Hi piru,
QuoteRemember to include a condition to hide the products again.
Here I just talked about maintaining the following line in the layout default.php. Nothing more.
<?php if (empty($this->category->haschildren) || !empty($this->keyword)) { ?>
Quote
ad Fix for Menu Item)
This was fix for bug with Page Layout which VM ignores, but if you don't use it, so you don't need it. You can revert to original script safely.
This was the answer to your questions:
Quote
should I upload again the original code from /components/com_virtuemart/views/category/view.html.php?
and
Quote
wich fix?
It's not important. You can safely ignore it ;-)...
Let me know if it works. Thank you.
Regards,
Pavel
Hi Pavel,
it works perfect!
I insert the code between FIX BEGIN and FIX END, and I included a condition to hide the products. Now work the search, I can see the categories, and I can see the products in each categorie.
Thank you so much!!! :)
Regards
piru
Hi,
I just installed thisone local with xampp, but there ist a problem because there is a white page. The error is:
Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\test\components\com_virtuemart\views\category\tmpl\default.php on line 369
I attached hier my whole file...
Thanks
sorry, its solved. I just change the file with another older and works.
Regards
piru