Jump to content

Prestashop 1.7 display content based on shop id with multistore in a tpl


pixelbee

Recommended Posts

  • 2 years later...
table style="width: 100%">
<tr>
	<td style="width: 50%">
		{if $logo_path}
			<!-- Original
			<img src="{$logo_path}" style="width:{$width_logo}px; height:{$height_logo}px;" />
			-->
			<img src="https://store.mob.co/mobco-baseline.png" style="width:150px; height:50px;" />
			<br><br>				
			{if isset($cart->id_shop) && $cart->id_shop == }
			<img src="{$logo_path}" style="width:100px; height:15px;" />
			<p> if test </p>
			{else}
			<img src="{$logo_path}" style="width:100px; height:35px;" />
			<!--<p> else test</p>-->
			{$id_shop}
			{/if}
			<br><br>
		{/if}

I'm trying to edit the following file: 

/html/pdf/header.tpl

Since the logo is being stretched out in different invoice templates for some unknown reason.

 

 

 

 

 

Link to comment
Share on other sites

11 hours ago, Nickovitshj said:
table style="width: 100%">
<tr>
	<td style="width: 50%">
		{if $logo_path}
			<!-- Original
			<img src="{$logo_path}" style="width:{$width_logo}px; height:{$height_logo}px;" />
			-->
			<img src="https://store.mob.co/mobco-baseline.png" style="width:150px; height:50px;" />
			<br><br>				
			{if isset($cart->id_shop) && $cart->id_shop == }
			<img src="{$logo_path}" style="width:100px; height:15px;" />
			<p> if test </p>
			{else}
			<img src="{$logo_path}" style="width:100px; height:35px;" />
			<!--<p> else test</p>-->
			{$id_shop}
			{/if}
			<br><br>
		{/if}

I'm trying to edit the following file: 

/html/pdf/header.tpl

Since the logo is being stretched out in different invoice templates for some unknown reason.

 

 

 

 

 

 

You need to two things , /Users/mac/Sites/localhost/ps/1.7.7.0/classes/pdf/HTMLTemplate.php line no  149 add this line 

'id_shop' =>$id_shop

it will look like 

        $this->smarty->assign([
            'logo_path' => Tools::getShopProtocol() . Tools::getMediaServer(_PS_IMG_) . _PS_IMG_ . $logo,
            'img_ps_dir' => Tools::getShopProtocol() . Tools::getMediaServer(_PS_IMG_) . _PS_IMG_,
            'img_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'),
            'date' => $this->date,
            'title' => $this->title,
            'shop_name' => $shop_name,
            'shop_details' => Configuration::get('PS_SHOP_DETAILS', null, null, (int) $id_shop),
            'width_logo' => $width,
            'height_logo' => $height,
            'id_shop'       =>$id_shop
        ]);

Now you are able to access the id_shop variable in smarty i have check this value  /html/pdf/header.tpl. and add bellow code , for my case it print in pdf the text . 

 

		{if $logo_path}
			<img src="{$logo_path}" style="width:{$width_logo}px; height:{$height_logo}px;" />

			{if isset($id_shop) && $id_shop == 1}
			<img src="{$logo_path}" style="width:100px; height:15px;" />
			<p> if test </p>
			{else}
			<p> if test  else</p>
			<img src="{$logo_path}" style="width:100px; height:35px;" />
			<!--<p> else test</p>-->
			{/if}

		{/if}

 

Hope now your issue will solved.

 

Thank you

  • Like 1
Link to comment
Share on other sites

  • 6 months later...
On 8/9/2021 at 7:49 PM, SmartDataSoft said:

 

You need to two things , /Users/mac/Sites/localhost/ps/1.7.7.0/classes/pdf/HTMLTemplate.php line no  149 add this line 

'id_shop' =>$id_shop

it will look like 

        $this->smarty->assign([
            'logo_path' => Tools::getShopProtocol() . Tools::getMediaServer(_PS_IMG_) . _PS_IMG_ . $logo,
            'img_ps_dir' => Tools::getShopProtocol() . Tools::getMediaServer(_PS_IMG_) . _PS_IMG_,
            'img_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'),
            'date' => $this->date,
            'title' => $this->title,
            'shop_name' => $shop_name,
            'shop_details' => Configuration::get('PS_SHOP_DETAILS', null, null, (int) $id_shop),
            'width_logo' => $width,
            'height_logo' => $height,
            'id_shop'       =>$id_shop
        ]);

Now you are able to access the id_shop variable in smarty i have check this value  /html/pdf/header.tpl. and add bellow code , for my case it print in pdf the text . 

 

		{if $logo_path}
			<img src="{$logo_path}" style="width:{$width_logo}px; height:{$height_logo}px;" />

			{if isset($id_shop) && $id_shop == 1}
			<img src="{$logo_path}" style="width:100px; height:15px;" />
			<p> if test </p>
			{else}
			<p> if test  else</p>
			<img src="{$logo_path}" style="width:100px; height:35px;" />
			<!--<p> else test</p>-->
			{/if}

		{/if}

 

Hope now your issue will solved.

 

Thank you

I need shop ID on the layout-both-column.tpl , this solution not working for me 

Can you help me please ? 

Link to comment
Share on other sites

Hey @nawres,

Is the layout-both-column.tpl in any way related to the pdf files for invoicing?
Because the solution found above is for exactly that. And not for somewhere else in the prestashop file structure.

Something that might be usefull for you is the following:
https://www.choosepizzi.net/prestashop-1-7-1-smarty-commands/

Edited by Nickovitshj (see edit history)
  • Like 1
Link to comment
Share on other sites

3 hours ago, Nickovitshj said:

Hey @nawres,

Is the layout-both-column.tpl in any way related to the pdf files for invoicing?
Because the solution found above is for exactly that. And now for somewhere else in the prestashop file structure.

Something that might be usefull for you is the following:
https://www.choosepizzi.net/prestashop-1-7-1-smarty-commands/

Hello , 

I think no relation with pdf files ; but thanks i found solution in the url you sent  by using $cart->id_shop

  • Like 1
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...