Page 1 of 1

Hide Description tab if there is no text?

Posted: Sat Dec 01, 2012 6:37 am
by frosty1_4me
Is it possible to hide that tab if there has been no description input?

Thanks very much.

Re: Hide Description tab if there is no text?

Posted: Sat Dec 01, 2012 2:31 pm
by rebdog
frosty1_4me wrote:Is it possible to hide that tab if there has been no description input?

Thanks very much.
Yes it is possible, you just need to make some changes in "catalog/view/theme/default/template/product/product.tpl" assuming you are using the default template or "catalog/view/theme/default/'template name'/product/product.tpl" if using a different template

You need to test if $description is empty so you need to wrap

Code: Select all

<a href="#tab-description"><?php echo $tab_description; ?></a>
and

Code: Select all

<div id="tab-description" class="tab-content"><?php echo $description; ?></div>
in a check to see if $description is empty, as below

Code: Select all

				
<?php if (!(ctype_space($description) || $description == '')) { ?>
<a href="#tab-description"><?php echo $tab_description; ?></a>
<?php } ?>
and

Code: Select all

<?php if (!(ctype_space($description) || $description == '')) { ?>
<div id="tab-description" class="tab-content"><?php echo $description; ?></div>
<?php } ?>
There is a vqmod attached that might help, if you are using the default template

Cheers

Re: Hide Description tab if there is no text?

Posted: Tue Dec 04, 2012 6:06 am
by frosty1_4me
That worked great! Thank you for taking the time to respond, much appreciated.

Re: Hide Description tab if there is no text?

Posted: Mon Jun 05, 2017 3:10 am
by hassni
Hi ,
I m using oc version 2.0.1.1 on Journal 2.9.4 . so this is same code i ve to paste in product.tpl

rebdog wrote:
Sat Dec 01, 2012 2:31 pm
frosty1_4me wrote:Is it possible to hide that tab if there has been no description input?

Thanks very much.
Yes it is possible, you just need to make some changes in "catalog/view/theme/default/template/product/product.tpl" assuming you are using the default template or "catalog/view/theme/default/'template name'/product/product.tpl" if using a different template

You need to test if $description is empty so you need to wrap

Code: Select all

<a href="#tab-description"><?php echo $tab_description; ?></a>
and

Code: Select all

<div id="tab-description" class="tab-content"><?php echo $description; ?></div>
in a check to see if $description is empty, as below

Code: Select all

				
<?php if (!(ctype_space($description) || $description == '')) { ?>
<a href="#tab-description"><?php echo $tab_description; ?></a>
<?php } ?>
and

Code: Select all

<?php if (!(ctype_space($description) || $description == '')) { ?>
<div id="tab-description" class="tab-content"><?php echo $description; ?></div>
<?php } ?>
There is a vqmod attached that might help, if you are using the default template

Cheers

Re: Hide Description tab if there is no text?

Posted: Mon Jun 05, 2017 3:11 am
by hassni
Hi ,
I m using oc version 2.0.1.1 on Journal 2.9.4 . so this is same code i ve to paste in product.tpl

rebdog wrote:
Sat Dec 01, 2012 2:31 pm
frosty1_4me wrote:Is it possible to hide that tab if there has been no description input?

Thanks very much.
Yes it is possible, you just need to make some changes in "catalog/view/theme/default/template/product/product.tpl" assuming you are using the default template or "catalog/view/theme/default/'template name'/product/product.tpl" if using a different template

You need to test if $description is empty so you need to wrap

Code: Select all

<a href="#tab-description"><?php echo $tab_description; ?></a>
and

Code: Select all

<div id="tab-description" class="tab-content"><?php echo $description; ?></div>
in a check to see if $description is empty, as below

Code: Select all

				
<?php if (!(ctype_space($description) || $description == '')) { ?>
<a href="#tab-description"><?php echo $tab_description; ?></a>
<?php } ?>
and

Code: Select all

<?php if (!(ctype_space($description) || $description == '')) { ?>
<div id="tab-description" class="tab-content"><?php echo $description; ?></div>
<?php } ?>
There is a vqmod attached that might help, if you are using the default template

Cheers

Re: Hide Description tab if there is no text?

Posted: Mon Jun 05, 2017 11:04 am
by chrisranjana.com
hassni wrote:
Mon Jun 05, 2017 3:11 am
Hi ,
I m using oc version 2.0.1.1 on Journal 2.9.4 . so this is same code i ve to paste in product.tpl
...
In file /catalog/view/theme/journal2/template/product/product.tpl

change the lines

Code: Select all

 <?php if (!$this->journal2->settings->get('hide_product_description')) { ?>
            <li <?php if ($is_active) { echo 'class="active"'; $is_active = false; } ;?>><a href="#tab-description" data-toggle="tab"><?php echo $tab_description; ?></a></li>
            <?php } ?>
as per rebdog advice above

Re: Hide Description tab if there is no text?

Posted: Wed Jun 07, 2017 9:17 am
by RideTheWave
In my theme's product.tpl file, through trial & error I found that commenting out the following block of lines removes the description tab for every product:

Code: Select all

<ul class="nav nav-tabs" role="tablist">
			        	<?php $i = 0; foreach($tabs as $tab) { $i++;
			        		$id = 'tab_'.$i;
			        		if($tab['content'] == 'description') { $id = 'tab-description'; }
			        		if($tab['content'] == 'attribute') { $id = 'tab-attribute'; }
			        		if($tab['content'] == 'review') { $id = 'tab-review'; }
			        		$class = false;
			        		if($i == 1) { $class = 'class="active"'; $new_active = $id; }
			        		echo '<li role="presentation" ' . $class . '><a href="#'.$id.'" aria-controls="'.$id.'" role="tab" data-toggle="tab">'.$tab['heading'].'</a></li>';
			        	} ?>
			        </ul>
			        <div class="tab-content">
			        <?php $i = 0; foreach($tabs as $tab) { $i++;
			        	$id = 'tab_'.$i;
			        	if($tab['content'] != 'description' && $tab['content'] != 'attribute' && $tab['content'] != 'review') {
			        		echo '<div id="'.$id.'" class="tab-pane';
			        		if($new_active == $id) { echo ' active'; }
			        		echo '" role="tabpanel">'.$tab['content'].'</div>';
			        	}
			        } ?>
So shouldn't it work if I place the recommended IF statement line:

Code: Select all

<?php if (!(ctype_space($description) || $description == '')) { ?>
before this block and

Code: Select all

<?php } ?>
at the end of this block? Because doing this doesn't seem to do anything - the description tab still appears for products with no description. It suggests to me that the IF statement is not working properly. Is there an alternate way to write up that IF statement?

Re: Hide Description tab if there is no text?

Posted: Sun Oct 28, 2018 6:08 pm
by shohag0910
please give instruction for 3.0.2.0