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

Show category description even if category has no products? [solved]

Started by ficciones, January 24, 2015, 00:30:50 AM

Previous topic - Next topic

ficciones

I am new to VM. I am using VM3.0.2 on Joomla 3.3.6
I have a menu item which is a vm category. It has sub-categories but no products. I want the category description to show, but it is not showing on the page; if I add a product to the category then the category description shows. 
I have tried modifying some files, for example "com_virtuemart\views\category\tmpl\default.php" line 35 I changed
if (empty($this->keyword) and !empty($this->category)) {
<div class="category_description">
   <?php echo $this->category->category_description; ?>
</div>
to:
if (empty($this->keyword) ) {
<div class="category_description">
   <?php echo $this->category->category_description; ?>
</div>
But it doesn't work. I did the same thing with template/html/com_virtuemart/category/default.php, but nothing happened either.

I think I may be missing something obvious, since this is my first try with virtuemart. Can anyone help?

GJC Web Design

if you try

print 'Debug Line '.__LINE__.' $this->category <pre>'; print_r ($this->category); print "</pre><br />\n";

above the if (empty($this->keyword) ) { 

is the desc there?
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

ficciones

Thank you for your response, I have tried adding the code, but unfortunately the debug information seems to be treated the same way as the category description - it does not appear when there are no products! If I publish a product in the category, then both appear- the debug and the cat description. And then yes, the cat description shows up in ther debug listing.

This is what I have in my template/html/com_virtuemart/category/default.php file:
<?php 
 print 
'Debug Line '.__LINE__.' $this->category <pre>'print_r ($this->category); print "</pre><br />\n";
if (empty($this->keyword) && !empty($this->category->category_description)) : ?>

<p class="category_description">
<?php echo $this->category->category_description?>
</p>
<?php endif; ?>


In configuration I set default template and category template to be "my_template-Default"; and I set category layout "No Override". Changing category layout to "Default" makes no difference.
I also added your line of code to the core file components/com_virtuemart/views/category/tmpl/default.php


GJC Web Design

hmm - must be filtered out further up the chain

have a poke around in administrator\components\com_virtuemart\models\category.php
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

ficciones

Not sure what I am doing (I am new to VM!) but the only place I found something could be happening is in line 170:

static public function getChildCategoryListObject($vendorId, $virtuemart_category_id,$selectedOrdering = null, $orderDir = null,$lang=false) {

if(!$lang){
$lang = VmConfig::$vmlang;
}

if(VmConfig::$defaultLang!=$lang and VmConfig::$langCount>1){
$query = 'SELECT c.*, IFNULL(l.category_name,ld.category_name) as category_name,
IFNULL(l.category_description,ld.category_description) as category_description,
IFNULL(l.metadesc,ld.metadesc) as metadesc,
IFNULL(l.metakey,ld.metakey) as metakey,
IFNULL(l.customtitle,ld.customtitle) as customtitle,
IFNULL(l.slug,ld.slug) as slug
FROM `#__virtuemart_categories` as c
INNER JOIN `#__virtuemart_categories_'.VmConfig::$defaultLang.'` as ld using (`virtuemart_category_id`)
LEFT JOIN `#__virtuemart_categories_'.$lang.'` as l using (`virtuemart_category_id`)';
} else {
$query = 'SELECT L.*
FROM `#__virtuemart_categories_'.$lang.'` as L
INNER JOIN `#__virtuemart_categories` as c using (`virtuemart_category_id`)';
}

I do have 2 languages, english (default) and spanish.
The output is the same in both languages, the category name and the category description are not showing without a published product.

ficciones

I found the problem. The code
if (empty($this->keyword) && !empty($this->category->category_description)) : ?>
<p class="category_description">
<?php echo $this->category->category_description?>
</p>
<?php endif; ?>

was actually nested inside another if statement that was also testing the condition if (!empty($this->products)) so I moved the block of code outside of it.
Please disregard my last post about languages.

ryan.schaffner

Sorry, I'm a bit new to this--but I'm trying to figure out how to do what you did. Can you paste the new code and where it's located? I don't want to screw things up...

Thanks!