Post by frosty1_4me » Sat Dec 01, 2012 6:37 am

Is it possible to hide that tab if there has been no description input?

Thanks very much.

New member

Posts

Joined
Thu Nov 29, 2012 12:10 pm

Post by rebdog » 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

Attachments

Do not display "Description Tab" if content is empty


Rebdog

Extra Product Tabs


Active Member

Posts

Joined
Sun Nov 04, 2012 5:50 pm
Location - Auckland, New Zealand

Post by frosty1_4me » Tue Dec 04, 2012 6:06 am

That worked great! Thank you for taking the time to respond, much appreciated.

New member

Posts

Joined
Thu Nov 29, 2012 12:10 pm

Post by hassni » Mon Jun 05, 2017 3:10 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

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

Newbie

Posts

Joined
Tue Oct 13, 2015 3:01 am

Post by hassni » 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

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

Newbie

Posts

Joined
Tue Oct 13, 2015 3:01 am

Post by chrisranjana.com » Mon Jun 05, 2017 11:04 am

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

Chris, Opencart Developers and Programmers,
www.chrisranjana.com


User avatar
Active Member

Posts

Joined
Thu Feb 26, 2009 2:23 am
Location - chennai, India

Post by RideTheWave » Wed Jun 07, 2017 9:17 am

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?

New member

Posts

Joined
Fri May 19, 2017 8:29 am
Who is online

Users browsing this forum: No registered users and 24 guests