News:

Support the VirtueMart project and become a member

Main Menu

Do not display product description if empty

Started by Picklehead, January 10, 2022, 01:43:15 AM

Previous topic - Next topic

Picklehead

Hi All,

Is there a way to hide the product description on product details page but only if the field is empty?

Any help would be great.

Phil.

AH

That is the default VM product view behaviour

if (!empty($this->product->product_desc)) {
Regards
A

Joomla 4.4.5
php 8.1

Picklehead

Thank you for the reply,

I do have the !empty code in my template but i am still seeing the description.

This is the code

   <?php  if (!empty($this->product->product_desc)) { ?>
        <h2> <?php echo JText::_('COM_VIRTUEMART_PRODUCT_DESC_TITLE'); ?></h2>
        <div>
           <?php echo '<div class="desc">' .$this->product->product_desc.'</div>'; ?>
         <?php
   if (!empty($this->product->customfieldsSorted['tags'])) {
   $this->position = 'tags';
   echo '<div class="tags">' .$this->loadTemplate('tags').'</div>';
   }
   ?>
        </div>
   <?php } ?>

But the description still shows even after clearing cache.


Jörgen

Change
<h2> <?php echo JText::_('COM_VIRTUEMART_PRODUCT_DESC_TITLE'); ?></h2>
to
<h2> <?php echo 'Descr title : ' .  JText::_('COM_VIRTUEMART_PRODUCT_DESC_TITLE'); ?></h2>

In order to see if this is the code that is used :)

Jörgen
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Picklehead

Thank you for the reply.

I have tested the code and the code extract posted is definitely being used.

Will investigate further and see if I can find the cause of the problem.

Kind Regards,
Phil


Jörgen

Are there maybe some invisible characters in the description ?

Jörgen
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Picklehead

Thanks again!

Checked again and no hidden characters in the description, so I am currently checking for conflicts with modules and plugins

Jörgen

Have You checked with str_len(description)?

Jörgen
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Picklehead

Hi Jörgen,
Thank you for the suggestion which I checked and everything  correct.

I have today been checking into this and found that if I have an editor enabled in Joomla then the product description displays despite being empty, but if set the Joomla Editor to 'None' then the description does not show. However this does not happen on any of my other themes so there must be something I am missing.

Kind Regards
Phil

Jörgen

Are you really sure that the description is empty ?

To me it looks like the editor puts in something like this:
<p>&nbsp;</p>

Check Your settings for the editor :)

Jörgen
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Picklehead

Hi,
Just a quick post to say that we found the issue.

We use SP Pagebuilder within on some of our product descriptions and we have modified our code to ensure the description fields always remain empty if using this plugin.

Thanks to all for the help!!

Phil

Jörgen

Glad to be of help. Looking for empty data in php works, usually the string is not empty after all...

Jörgen
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.