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

Re: Hide Description tab if there is no text?

Posted: Thu Dec 09, 2021 7:04 am
by NadezhdaSmirnova
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
Please help me fix the modifier from opencart 2.0 under 3.0 where twigs are already used. I need to hide the description tab if it is empty. Php conditions in twigs do not work. The template is standard, the modifier is attached. Thanks a lot!

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <name>Скрыть вкладку с описанием без текста</name>
    <code>hide_description_tab_without_text</code>
    <version></version>
    <author></author>
    <link></link>
    <file path="catalog/view/theme/default/template/product/product.twig">
        <operation>
            <search>
                <![CDATA[<li class="active"><a href="#tab-description" data-toggle="tab">{{ tab_description }}</a></li>]]>
            </search>
            <add position="replace">
                <![CDATA[<?php if ($description) { ?><li class="active"><a href="#tab-description" data-toggle="tab">{{ tab_description }}</a></li><?php } ?>]]>
            </add>
        </operation>
        <operation>
            <search>
                <![CDATA[<div class="tab-pane active" id="tab-description">{{ description }}</div>]]>
            </search>
            <add position="replace">
                <![CDATA[<?php if ($description) { ?><div class="tab-pane active" id="tab-description">{{ description }}</div><?php } ?>]]>
            </add>
        </operation>
    </file>
</modification>

Re: Hide Description tab if there is no text?

Posted: Thu Dec 09, 2021 4:06 pm
by xxvirusxx
NadezhdaSmirnova wrote:
Thu Dec 09, 2021 7:04 am

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <name>Скрыть вкладку с описанием без текста</name>
    <code>hide_description_tab_without_text</code>
    <version></version>
    <author></author>
    <link></link>
    <file path="catalog/view/theme/default/template/product/product.twig">
        <operation>
            <search>
                <![CDATA[<li class="active"><a href="#tab-description" data-toggle="tab">{{ tab_description }}</a></li>]]>
            </search>
            <add position="replace">
                <![CDATA[{% if description %} <li class="active"><a href="#tab-description" data-toggle="tab">{{ tab_description }}</a></li>{% endif %}]]>
            </add>
        </operation>
        <operation>
            <search>
                <![CDATA[<div class="tab-pane active" id="tab-description">{{ description }}</div>]]>
            </search>
            <add position="replace">
                <![CDATA[{% if description %}<div class="tab-pane active" id="tab-description">{{ description }}</div>{% endif %}]]>
            </add>
        </operation>
    </file>
</modification>

Re: Hide Description tab if there is no text?

Posted: Thu Dec 09, 2021 9:52 pm
by NadezhdaSmirnova
xxvirusxx wrote:
Thu Dec 09, 2021 4:06 pm
NadezhdaSmirnova wrote:
Thu Dec 09, 2021 7:04 am

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <name>Скрыть вкладку с описанием без текста</name>
    <code>hide_description_tab_without_text</code>
    <version></version>
    <author></author>
    <link></link>
    <file path="catalog/view/theme/default/template/product/product.twig">
        <operation>
            <search>
                <![CDATA[<li class="active"><a href="#tab-description" data-toggle="tab">{{ tab_description }}</a></li>]]>
            </search>
            <add position="replace">
                <![CDATA[{% if description %} <li class="active"><a href="#tab-description" data-toggle="tab">{{ tab_description }}</a></li>{% endif %}]]>
            </add>
        </operation>
        <operation>
            <search>
                <![CDATA[<div class="tab-pane active" id="tab-description">{{ description }}</div>]]>
            </search>
            <add position="replace">
                <![CDATA[{% if description %}<div class="tab-pane active" id="tab-description">{{ description }}</div>{% endif %}]]>
            </add>
        </operation>
    </file>
</modification>
Thank you very much. Can you tell me how to activate the tab with attributes?

Re: Hide Description tab if there is no text?

Posted: Thu Dec 09, 2021 10:01 pm
by xxvirusxx
Edit a product then add Attributes

Re: Hide Description tab if there is no text?

Posted: Thu Dec 09, 2021 10:39 pm
by NadezhdaSmirnova
xxvirusxx wrote:
Thu Dec 09, 2021 10:01 pm
Edit a product then add Attributes
Attributes are) The tab is not activated.

Re: Hide Description tab if there is no text?

Posted: Thu Dec 09, 2021 10:53 pm
by NadezhdaSmirnova
So does not show the attributes. Only after clicking on the tab.

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <name>Скрыть вкладку с описанием без текста</name>
    <code>hide_description_tab_without_text</code>
    <version></version>
    <author></author>
    <link></link>
    <file path="catalog/view/theme/default/template/product/product.twig">
        <operation>
            <search>
                <![CDATA[<li class="active"><a href="#tab-description" data-toggle="tab">{{ tab_description }}</a></li>]]>
            </search>
            <add position="replace">
                <![CDATA[{% if description %} <li class="active"><a href="#tab-description" data-toggle="tab">{{ tab_description }}</a></li>{% endif %}]]>
            </add>
        </operation>
        <operation>
            <search>
                <![CDATA[<div class="tab-pane active" id="tab-description">{{ description }}</div>]]>
            </search>
            <add position="replace">
                <![CDATA[{% if description %}<div class="tab-pane active" id="tab-description">{{ description }}</div>{% endif %}]]>
            </add>
        </operation>
        <operation>
            <search>
                <![CDATA[<li><a href="#tab-specification" data-toggle="tab">{{ tab_attribute }}</a></li>]]>
            </search>
            <add position="replace">
                <![CDATA[<li class="active"><a href="#tab-specification" data-toggle="tab">{{ tab_attribute }}</a></li>]]>
            </add>
        </operation>
    </file>
</modification>

Re: Hide Description tab if there is no text?

Posted: Thu Dec 09, 2021 10:56 pm
by xxvirusxx
Then delete this code

Code: Select all

        <operation>
            <search>
                <![CDATA[<li><a href="#tab-specification" data-toggle="tab">{{ tab_attribute }}</a></li>]]>
            </search>
            <add position="replace">
                <![CDATA[<li class="active"><a href="#tab-specification" data-toggle="tab">{{ tab_attribute }}</a></li>]]>
            </add>
        </operation>

Re: Hide Description tab if there is no text?

Posted: Thu Dec 09, 2021 11:46 pm
by NadezhdaSmirnova
xxvirusxx wrote:
Thu Dec 09, 2021 10:56 pm
Then delete this code

Code: Select all

        <operation>
            <search>
                <![CDATA[<li><a href="#tab-specification" data-toggle="tab">{{ tab_attribute }}</a></li>]]>
            </search>
            <add position="replace">
                <![CDATA[<li class="active"><a href="#tab-specification" data-toggle="tab">{{ tab_attribute }}</a></li>]]>
            </add>
        </operation>
It does not display characteristics like this, the tab is active, but does not show characteristics. I tried to add more like this:

Code: Select all

        <operation>
            <search>
                <![CDATA[<div class="tab-pane active" id="tab-description">{{ description }}</div>]]>
            </search>
            <add position="replace">
                <![CDATA[<div class="tab-pane id="tab-description">{{ description }}</div>]]>
            </add>
        </operation>
        <operation>
            <search>
                <![CDATA[<div class="tab-pane" id="tab-specification">]]>
            </search>
            <add position="replace">
                <![CDATA[<div class="tab-pane" active id="tab-specification">]]>
            </add>
        </operation>
All the same does not display, you need to click on the adjacent tab and switch back. Why is it not always easy with an opencart?

Re: Hide Description tab if there is no text?

Posted: Fri Dec 10, 2021 12:21 am
by OSWorX
NadezhdaSmirnova wrote:
Thu Dec 09, 2021 11:46 pm
Why is it not always easy with an opencart?
OpenCart itself IS easy to handle.
Mostly the "problem" is the User In Front Of The Screen (aka BUFOS) ..

Re: Hide Description tab if there is no text?

Posted: Fri Dec 10, 2021 12:52 am
by xxvirusxx
NadezhdaSmirnova wrote:
Thu Dec 09, 2021 11:46 pm
All the same does not display, you need to click on the adjacent tab and switch back. Why is it not always easy with an opencart?
Because class active is already set for Description....
And you need to make an extra change to set class active for Attributes when Description is empty.

Code: Select all

        <operation>
            <search>
                <![CDATA[<li><a href="#tab-specification" data-toggle="tab">{{ tab_attribute }}</a></li>]]>
            </search>
            <add position="replace">
                <![CDATA[
                {% if  description %}
                <li><a href="#tab-specification" data-toggle="tab">{{ tab_attribute }}</a></li>
                {% else %}
                <li class="active"><a href="#tab-specification" data-toggle="tab">{{ tab_attribute }}</a></li>
                {% endif %}
                ]]>
            </add>
        </operation>

Re: Hide Description tab if there is no text?

Posted: Fri Dec 10, 2021 1:08 am
by NadezhdaSmirnova
xxvirusxx wrote:
Fri Dec 10, 2021 12:52 am
NadezhdaSmirnova wrote:
Thu Dec 09, 2021 11:46 pm
All the same does not display, you need to click on the adjacent tab and switch back. Why is it not always easy with an opencart?
Because class active is already set for Description....
And you need to make an extra change to set class active for Attributes when Description is empty.

Code: Select all

        <operation>
            <search>
                <![CDATA[<li><a href="#tab-specification" data-toggle="tab">{{ tab_attribute }}</a></li>]]>
            </search>
            <add position="replace">
                <![CDATA[
                {% if  description %}
                <li><a href="#tab-specification" data-toggle="tab">{{ tab_attribute }}</a></li>
                {% else %}
                <li class="active"><a href="#tab-specification" data-toggle="tab">{{ tab_attribute }}</a></li>
                {% endif %}
                ]]>
            </add>
        </operation>
Thank you sincerely. I slightly tweaked the code, below is a ready-made working solution. If the description is not filled in, the tab with characteristics is activated, in the same way you can hide the characteristics if they are not filled in, and activate the tab with reviews.

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <name>Скрыть вкладку с описанием без текста</name>
    <code>hide_description_tab_without_text</code>
    <version></version>
    <author></author>
    <link></link>
    <file path="catalog/view/theme/default/template/product/product.twig">
        <operation>
            <search>
                <![CDATA[<li class="active"><a href="#tab-description" data-toggle="tab">{{ tab_description }}</a></li>]]>
            </search>
            <add position="replace">
                <![CDATA[{% if description %}<li class="active"><a href="#tab-description" data-toggle="tab">{{ tab_description }}</a></li>{% endif %}]]>
            </add>
        </operation>
        <operation>
            <search>
                <![CDATA[<div class="tab-pane active" id="tab-description">{{ description }}</div>]]>
            </search>
            <add position="replace">
                <![CDATA[{% if description %}<div class="tab-pane active" id="tab-description">{{ description }}</div>{% endif %}]]>
            </add>
        </operation>
        <operation>
            <search>
                <![CDATA[<li><a href="#tab-specification" data-toggle="tab">{{ tab_attribute }}</a></li>]]>
            </search>
            <add position="replace">
                <![CDATA[
                {% if  description %}
                <li><a href="#tab-specification" data-toggle="tab">{{ tab_attribute }}</a></li>
                {% else %}
                <li class="active"><a href="#tab-specification" data-toggle="tab">{{ tab_attribute }}</a></li>
                {% endif %}
                ]]>
            </add>
        </operation>
        <operation>
            <search>
                <![CDATA[<div class="tab-pane" id="tab-specification">]]>
            </search>
            <add position="replace">
                <![CDATA[
                {% if  description %}
                <div class="tab-pane" id="tab-specification">
                {% else %}
                <div class="tab-pane active" id="tab-specification">
                {% endif %}
                ]]>
            </add>
        </operation>
    </file>
</modification>

Re: Hide Description tab if there is no text?

Posted: Fri Dec 10, 2021 1:12 am
by NadezhdaSmirnova
xxvirusxx Thank you very much again!