Jump to content

Hide "MORE DETAILS" button when description is empty?


Recommended Posts

Hi everyone,

 

It's not a big issue, but I'm trying to make Prestashop hide "MORE DETAILS" button in product description page through template files, when product contains no description to scroll down to. The thing is, I'm not sure what kind of script should be used (not enough experience on that field). Maybe someone willing to help me? Any help would be greatly appreciated!

Link to comment
Share on other sites

Hi Milos,

 

thanks for quick reply - I'm using prestashop 1.4.8.2 and theme is custom made. The button I'm trying to toggle according the description tab is actually for videos - I'm using opensum videos module found on this forum, and they had a great code for hiding video tab whenever the tab is empty, but it doesn't hide video button, which is cloned into product.tpl file just like more details button:

			{if $product->description}
				<p class="buttons_bottom_block">
			<a href="javascript:{ldelim}{rdelim}" class="more_info_button">{l s='More details'}</a></br>			
			<a href="javascript:{ldelim}{rdelim}" class="video_button">{l s='Watch product video'}</a>
			</p>
			{/if}

While I do not have any PHP experience, I made some tinkering according to video module - I've added function to modules/productvideos/productvideos.php:

	function ShowVideoButton($params){
        global $smarty;
        $db = Db::getInstance();

        $id_product=Tools::getValue('id_product');
        $selectvideo="SELECT * FROM  `"._DB_PREFIX_."product_videos` where product_id='$id_product' limit 0,1";
        $resultvideo = Db::getInstance()->ExecuteS($selectvideo);

        $resultvideo= (count($resultvideo)>0 ? $resultvideo[0] : NULL );
		
		    if ($resultvideo === NULL){
            $smarty->assign('do_not_display_video_button', 'yes');
            return false;
        }
		
    }

And then changed product.tpl file by adding IF operator to toggle the video button:

			{/if}
			{if $product->description}
				<p class="buttons_bottom_block">
			<a href="javascript:{ldelim}{rdelim}" class="more_info_button">{l s='More details'}</a></br>

			{if !isset($do_not_display_video_button)}			
			<a href="javascript:{ldelim}{rdelim}" class="video_button">{l s='Watch product video'}</a>
			{/if}

			</p>
			{/if}

But this function doesn't work, I don't know why.

Link to comment
Share on other sites

Hi again Milos,

 

Thanks for the suggestion! I did the change, but something else must be wrong, still not working... Maybe I should clear the smarty cache?

 

EDIT: I have manualy emptied the cache, no effect. Something's probably wrong with the coding.

Edited by sting5 (see edit history)
Link to comment
Share on other sites

I did it! If anyone will try to toggle video button in product page accordingly to video module, there's no need to duplicate the function in productvideos.php like I did previously, simply add 

 

"$smarty->assign('do_not_display_video_button', 'yes');"

 

in the existing function "hookProductTab" in the productvideos.php file, and add "{if !isset($do_not_display_video_button)}" and "{/if}operators before and after the button code in product.tpl file, then everything works fine.

 

You can close this topic as solved. Thanks again Milos for all the suggestions You've provided!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...