pixelbee Posted December 4, 2018 Share Posted December 4, 2018 Hot to display different content based on shop id with multistore in a tpl file? I have tryed with the below code, but not work. Anyone can help me? {if $shop.shop.id==1} Business Customer {else} Private Customer {/if} Link to comment Share on other sites More sharing options...
Nickovitshj Posted August 6, 2021 Share Posted August 6, 2021 I'm looking for this logic as well. To edit the header.tpl file which is used for invoice and credit slip pdf's. Link to comment Share on other sites More sharing options...
SmartDataSoft Posted August 6, 2021 Share Posted August 6, 2021 @Nickovitshj Can you please give some screen shot what kind of things you like to do. I will try to help you Thank you Link to comment Share on other sites More sharing options...
Nickovitshj Posted August 9, 2021 Share Posted August 9, 2021 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 More sharing options...
SmartDataSoft Posted August 9, 2021 Share Posted August 9, 2021 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 1 Link to comment Share on other sites More sharing options...
Nickovitshj Posted August 10, 2021 Share Posted August 10, 2021 @SmartDataSoft, thank you very much. That indeed did the fix. So I suppose in order to use certain data in the invoices and credit slips we first need to specify them somewhere in the PDF classes. Is there any clear documentation on this somewhere? Link to comment Share on other sites More sharing options...
SmartDataSoft Posted August 10, 2021 Share Posted August 10, 2021 @Nickovitshj If you check in the php file you will understand that variable can accessable from tpl file which is assigned . In this tpl all variable is not send like frontend. I have manually dig those file code for you. Thank you 😊 1 Link to comment Share on other sites More sharing options...
nawres Posted February 15, 2022 Share Posted February 15, 2022 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 More sharing options...
Nickovitshj Posted February 17, 2022 Share Posted February 17, 2022 (edited) 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 February 17, 2022 by Nickovitshj (see edit history) 1 Link to comment Share on other sites More sharing options...
nawres Posted February 17, 2022 Share Posted February 17, 2022 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 1 Link to comment Share on other sites More sharing options...
Nickovitshj Posted February 17, 2022 Share Posted February 17, 2022 1 minute ago, nawres said: Hello , I think no relation with pdf files ; but thanks i found solution in the url you sent by using $cart->id_shop Ok, make sure to check if it's showing the correct ID by checking with your database values. Check it for multiple shops. Link to comment Share on other sites More sharing options...
nawres Posted February 17, 2022 Share Posted February 17, 2022 Just now, Nickovitshj said: Ok, make sure to check if it's showing the correct ID by checking with your database values. Check it for multiple shops. OK ,i already use multishop in my project , thnks Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now