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

New member

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

New member

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,
Opencart Developers Opencart Programmers
https://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

Post by shohag0910 » Sun Oct 28, 2018 6:08 pm

please give instruction for 3.0.2.0

Newbie

Posts

Joined
Sun Sep 04, 2016 4:06 pm

Post by NadezhdaSmirnova » Thu Dec 09, 2021 7:04 am

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>


Posts

Joined
Thu Dec 09, 2021 6:43 am

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

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by NadezhdaSmirnova » Thu Dec 09, 2021 9:52 pm

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?

Attachments

Screenshot_34.png

Screenshot_34.png (3.86 KiB) Viewed 5679 times



Posts

Joined
Thu Dec 09, 2021 6:43 am

Post by xxvirusxx » Thu Dec 09, 2021 10:01 pm

Edit a product then add Attributes

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by NadezhdaSmirnova » Thu Dec 09, 2021 10:39 pm

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

Attachments

Screenshot_35.png

Screenshot_35.png (17.62 KiB) Viewed 5658 times



Posts

Joined
Thu Dec 09, 2021 6:43 am

Post by NadezhdaSmirnova » Thu Dec 09, 2021 10:53 pm

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>


Posts

Joined
Thu Dec 09, 2021 6:43 am

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

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by NadezhdaSmirnova » Thu Dec 09, 2021 11:46 pm

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?

Attachments

Screenshot_37.png

Attributes not visible - Screenshot_37.png (14.64 KiB) Viewed 5636 times

Screenshot_36.png

After activating the owner through the neighboring - Screenshot_36.png (30.25 KiB) Viewed 5636 times



Posts

Joined
Thu Dec 09, 2021 6:43 am

Post by OSWorX » Fri Dec 10, 2021 12:21 am

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) ..

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

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

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by NadezhdaSmirnova » Fri Dec 10, 2021 1:08 am

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>


Posts

Joined
Thu Dec 09, 2021 6:43 am

Post by NadezhdaSmirnova » Fri Dec 10, 2021 1:12 am

xxvirusxx Thank you very much again!


Posts

Joined
Thu Dec 09, 2021 6:43 am
Who is online

Users browsing this forum: No registered users and 5 guests