matteth Posted September 15, 2010 Share Posted September 15, 2010 I tried to find out how I could get the URL of the current page into my .tpl-file. Finally found a way, PHP variables through Smarty:{$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI}This could for example be used to put a Facebook like button on the products.tpl that enables the user to like a specific item:<iframe src="http://www.facebook.com/plugins/like.php?href={$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI}&layout=button_count&show_faces=true&width=450&action=like&colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:21px;" allowTransparency="true"></iframe>Do you know of a better way? Please let me know /Mats 10 Link to comment Share on other sites More sharing options...
crazy_commi Posted March 27, 2011 Share Posted March 27, 2011 This is just exactly what i've been looking for! Thank you Matteth, you saved my day! Link to comment Share on other sites More sharing options...
cagrie Posted April 2, 2011 Share Posted April 2, 2011 mine too ^^ Link to comment Share on other sites More sharing options...
matteth Posted April 2, 2011 Author Share Posted April 2, 2011 Great Link to comment Share on other sites More sharing options...
GS VISION Posted June 29, 2011 Share Posted June 29, 2011 I used /product.php?id_product={$smarty.get.id_product}& but yours is better for mod_rewrite links and maybe I`ll consider changing. Thanks for the hint. Link to comment Share on other sites More sharing options...
Richard S Posted June 30, 2011 Share Posted June 30, 2011 You can also use global variable $currentIndex and pass it to Smarty template files. It's very handy on modules. Link to comment Share on other sites More sharing options...
stephane-v Posted August 9, 2011 Share Posted August 9, 2011 You can also use : {$link->getProductLink($product)} It also works with mod_rewrite links. Stéphane 3 Link to comment Share on other sites More sharing options...
JJ Choo Posted October 2, 2011 Share Posted October 2, 2011 may I know how I can I use this method to highlight the menu of the current page ? Thanks in advance. Link to comment Share on other sites More sharing options...
Jupiterr Posted January 4, 2012 Share Posted January 4, 2012 You can use this on your menu to know in where category/product you are. Anyway, it's recommended to activate friendly URLS. This applies the "Current" CSS style to that special button. <li class="{if {$smarty.server.REQUEST_URI} == 'category.php?id_category=31'}current{/if}"> Good luck! 1 Link to comment Share on other sites More sharing options...
chetwyn Posted March 10, 2012 Share Posted March 10, 2012 was looking for exactly this ! Link to comment Share on other sites More sharing options...
TWDesign Posted March 12, 2012 Share Posted March 12, 2012 Thats very close to what I want to do. I want to add an anchor link on the page but I want the link to be dynamic based on the URL of the current page. e.g. If the current url is http://www.mydomain.com/en/widget.html then add a link to the English "Contact Us" page. If the current url is http://www.mydomain.com/jp/widget.html then add a link to the Japanese "Contact Us" page. What would be even cooler is if there is a Smarty variable that detects the language setting of the current page. Is there a Smarty Variable for that too? Link to comment Share on other sites More sharing options...
alexafuentes Posted July 1, 2012 Share Posted July 1, 2012 I used this and it works, but the only problem is that when I turn "Force Compilation" to no, the link selected is the one of the last page I visited. Don't know how to fix, I would appreciate your help Link to comment Share on other sites More sharing options...
Liofey Posted December 19, 2012 Share Posted December 19, 2012 wow this is exactly what i am searching for. thank you Link to comment Share on other sites More sharing options...
silentRun Posted July 16, 2013 Share Posted July 16, 2013 You can also use this code: {if $page_name == 'index'} <div class="home"> {else} <div> {/if} Link to comment Share on other sites More sharing options...
theme_designer Posted July 18, 2013 Share Posted July 18, 2013 Will that work on latest PS version? Link to comment Share on other sites More sharing options...
Jiten rash (away) Posted July 19, 2013 Share Posted July 19, 2013 <form id="form1" name="form1" method="post" action=""> <label> <input name="textarea" type="text" id="textarea" value="" size="45" /> </label> <a href="{$link->getPageLink('example')}">{l s='example' mod='the linl'}</a> </form> u will get the link there..!! 1 Link to comment Share on other sites More sharing options...
ben mbarek afef Posted December 23, 2013 Share Posted December 23, 2013 (edited) hello, how i can get the current shop_url in my php file Edited December 23, 2013 by ben mbarek afef (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted December 23, 2013 Share Posted December 23, 2013 hello what you exactly mean by shop_url ? main page of your shop? Link to comment Share on other sites More sharing options...
ben mbarek afef Posted December 23, 2013 Share Posted December 23, 2013 yes thank you i found the answer Link to comment Share on other sites More sharing options...
vekia Posted December 23, 2013 Share Posted December 23, 2013 and the solution is... ? can you share it please, im more than convinced that it will be helpful for other merchants here thanks in advance Link to comment Share on other sites More sharing options...
vinskate Posted April 18, 2014 Share Posted April 18, 2014 (edited) As usual... no replyIn php, you can find url with $_SERVER["REQUEST_URI"]; example: LINK: http://localhost:80/mon-site/page-blog/ $_SERVER["REQUEST_URI"]: /mon-site/page-blog/ Edited April 18, 2014 by vinskate (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted April 18, 2014 Share Posted April 18, 2014 As usual... no reply it's not so usual as you said in smarty: http://{$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI} 4 Link to comment Share on other sites More sharing options...
davers44 Posted April 21, 2014 Share Posted April 21, 2014 Hi, that's an interesting thread. I am trying to change width of columns to get a larger column at some pages like the checkout process . ( still using PS 1.4) I already modified the header.tpl shown below to include and IF condition with a custom larger id="center_column_large" which I included in the global.css {if ($page_name == 'order' ) || ($page_name == 'order-confirmation' ) || ($page_name == 'authentication' )} <div id="custom_large_center_column" class="center_column"> {else} <div id="center_column" class="center_column"> {/if} Everything works perfect with the page specified above but it seems to work only with basic page name located at the root of prestashop. I am not able to add other transaction pages of some payments modules like $page_name == '/modules/bankwire/payment.php' located in deeper subdirectories. I tried $page_name == 'modules/bankwire/payment' and $page_name == 'payment' and also $page_name == 'payment.php' no way I can get such page recognized in the IF condition above. I am very close and don't seem so difficult, am I missing something? Thanks Link to comment Share on other sites More sharing options...
vekia Posted April 21, 2014 Share Posted April 21, 2014 $page_name == 'modules/bankwire/payment' modules/bankwire/payment is not a page name in payment.php file located in bankwire directory (controllers/front subdirectory) add public $php_self = 'bankwire'; then you will be able to use $page-name == 'bankwire' Link to comment Share on other sites More sharing options...
davers44 Posted April 22, 2014 Share Posted April 22, 2014 Thanks, it seems a great solution but I am afraid it works only with PS 1.5 In PS1.4 the payment.php of the bankwire module is located at .../modules/bankwire/payment.php and not under controllers. I tried anyway to add public $php_self = 'bankwire' to the payment.php anyway that give unexpected error. Any idea how to get same result on PS1.4? Thanks! Link to comment Share on other sites More sharing options...
vekia Posted April 26, 2014 Share Posted April 26, 2014 Thanks, it seems a great solution but I am afraid it works only with PS 1.5 In PS1.4 the payment.php of the bankwire module is located at .../modules/bankwire/payment.php and not under controllers. I tried anyway to add public $php_self = 'bankwire' to the payment.php anyway that give unexpected error. Any idea how to get same result on PS1.4? Thanks! yes, unfortunately in prestashop 1.4 it will not work. you can use condition like: {assign var="url" value=$smarty.server.HTTP_HOST$smarty.server.REQUEST_URI} {if $url=="http://yourwebsite.com/modules/bankwire/payment.php} do something {/if} {if 1 Link to comment Share on other sites More sharing options...
davers44 Posted April 27, 2014 Share Posted April 27, 2014 That is just perfect, it allows you to target any page needed. Thanks a lot Vekia! Link to comment Share on other sites More sharing options...
vekia Posted April 27, 2014 Share Posted April 27, 2014 that's right and you're welcome, of course happy coding! Link to comment Share on other sites More sharing options...
Richard S Posted July 1, 2014 Share Posted July 1, 2014 For those who searches this forum from search engines. The solution is to use global smarty variable in PrestaShop {$request} instead of {$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI}.Works in PS.16, did not check if available on PS1.5 Link to comment Share on other sites More sharing options...
Ciuki Posted August 2, 2014 Share Posted August 2, 2014 Was looking for this myself, found the {$come_from} global smarty variable. Link to comment Share on other sites More sharing options...
vekia Posted August 2, 2014 Share Posted August 2, 2014 For those who searches this forum from search engines. The solution is to use global smarty variable in PrestaShop {$request} instead of {$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI}. Works in PS.16, did not check if available on PS1.5 it returns also variables defined in $_GET ? Link to comment Share on other sites More sharing options...
shri Posted February 20, 2015 Share Posted February 20, 2015 Hi, I have multishop so i need to check which shop is currently being used to determine which copyright text to display. Can anyone help? this is the code from block cms <div> Copyright © i.net.au 1997-2015 </div> if url = i.net.au than Copyright © i.net.au 1997-2015 else Copyright © pcm.com.au 1997-2015 Can anyone help ?? Link to comment Share on other sites More sharing options...
shri Posted February 24, 2015 Share Posted February 24, 2015 I got the solution. Link to comment Share on other sites More sharing options...
rololo88 Posted April 2, 2015 Share Posted April 2, 2015 it's not so usual as you said in smarty: http://{$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI} Thanks Vekia , once again you save my day!! Link to comment Share on other sites More sharing options...
abdess Posted February 14, 2017 Share Posted February 14, 2017 it's not so usual as you said in smarty: http://{$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI} Thanks a lot Vekia! 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