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.
That is the default VM product view behaviour
if (!empty($this->product->product_desc)) {
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.
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
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
Are there maybe some invisible characters in the description ?
Jörgen
Thanks again!
Checked again and no hidden characters in the description, so I am currently checking for conflicts with modules and plugins
Have You checked with str_len(description)?
Jörgen
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
Are you really sure that the description is empty ?
To me it looks like the editor puts in something like this:
<p> </p>
Check Your settings for the editor :)
Jörgen
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
Glad to be of help. Looking for empty data in php works, usually the string is not empty after all...
Jörgen