Jump to content

Hide Manufacturer Logo If empty


toppetsales

Recommended Posts

Hi!

Prestashop 1.6 developer here. I created a section where it shows the Manufacturer's logo on the product page (product.tpl). If there are no uploaded logo files uploaded for a manufacturer, I want to hide that section. Is that possible? This is my code.

{if !empty($product->id_manufacturer)}
  <div class="product-brand-logo">
      <a href="{$link->getmanufacturerLink($product->id_manufacturer, $product->link_rewrite)}" title="{l s=''}">
        	<img src="{$base_dir}img/m/{$product->id_manufacturer}.jpg" alt="{$product->manufacturer_name|escape:'htmlall':'UTF-8'}" title="{$product->manufacturer_name|escape:'htmlall':'UTF-8'}" />
      </a>	
  </div>				
{/if}

My condition only works if there are no manufacturers assigned to the product. I also want to hide it if there are no logos uploaded on the manufacturer assigned.

Thanks!

Link to comment
Share on other sites

3 hours ago, Nishith said:

Hi..
you need use {if file_exists(your_file_path)} function of your code

Thanks

 

Awesome. That worked perfectly. Here's my code in case anyone needs it:

 

{assign var="brandlogo" value="/var/www/html/img/m/{$product->id_manufacturer}.jpg"}
{if file_exists($brandlogo)}
  <div class="product-brand-logo">
      <a href="{$link->getmanufacturerLink($product->id_manufacturer, $product->link_rewrite)}" title="{l s=''}">
      	<img src="{$base_dir}img/m/{$product->id_manufacturer}.jpg" alt="{$product->manufacturer_name|escape:'htmlall':'UTF-8'}" title="{$product->manufacturer_name|escape:'htmlall':'UTF-8'}" />
    </a>	
  </div>				
{/if}

Thanks, @Nishith

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