sixthmind Posted March 8, 2012 Share Posted March 8, 2012 I have created a custom template and now I need to check if the page we are viewing is using that template and do something if it is. I understand we have global variable $page_name In header.tpl and I can currently use: {if $page_name == 'index'} {if $page_name == 'cms'} How would I do something like: if $page_name = 'custom-template' ? or anything alternative which would check the current page so I can then do something if on that page. I found $smarty.template, but if put in header.tpl, the template it shows is header.tpl of course. Any suggestion how to solve this problem? Your help would be really appreciated. Link to comment Share on other sites More sharing options...
Nuvish Posted March 8, 2012 Share Posted March 8, 2012 Hello, Doesn't {if $page_name == 'custom-template'} work? It should work,provided that you created the page well. 1. Create a php file at root. (eg custom-template.php) 2.Point the custom-template.php to a newly created controller in folder controllers (eg customTemplateController.php) 3. The controller then uses function displayContent() to redirect to your custom-template.tpl In the customTemplateController.php, add this line : public $php_self = 'custom-template.php'; Then you will surely be able to use $page_name == 'custom-template'. Hope this helps. 1 Link to comment Share on other sites More sharing options...
sixthmind Posted March 8, 2012 Author Share Posted March 8, 2012 Hi Martyn Thanks so much for your help! I didn't know how everything works, but I added public $php_self etc. and now it works the way I wanted. You made my day! Thank you. Link to comment Share on other sites More sharing options...
radovan Posted October 18, 2012 Share Posted October 18, 2012 hm its not work for version 1.5 ? Link to comment Share on other sites More sharing options...
Rahvin Posted January 14, 2013 Share Posted January 14, 2013 hm its not work for version 1.5 ? I don't get it to work in 1.5.3 either. Any idea how to get it work? Link to comment Share on other sites More sharing options...
lipo999 Posted September 12, 2018 Share Posted September 12, 2018 Hello, how to make it for payment modules? {if $page_name == '??????'} For e.g. I would like show (or not show) in validation page of COD (/module/cashondeliveryplus/validation). Thank you 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