sphway Posted May 1, 2022 Share Posted May 1, 2022 I create a simple module and try to get current page name(like: women-cloth) or current page url (like: www.***.com/en/women), I use {$page_name} or {$urls.current_url} in .tpl,but doesn't work. anyone can tell me why? thanks Link to comment Share on other sites More sharing options...
endriu107 Posted May 1, 2022 Share Posted May 1, 2022 Add to your tpl {debug} you will see all variable you have access. Link to comment Share on other sites More sharing options...
sphway Posted May 1, 2022 Author Share Posted May 1, 2022 1 hour ago, endriu107 said: Add to your tpl {debug} you will see all variable you have access. Thanks for your reply,I debug the {$urls.current_url} and {$page_name},they are all null Link to comment Share on other sites More sharing options...
abdullacm Posted May 2, 2022 Share Posted May 2, 2022 10 hours ago, sphway said: Thanks for your reply,I debug the {$urls.current_url} and {$page_name},they are all null did you try the way as endriu107 suggested, and did you see these variables inside the debug popup ? Link to comment Share on other sites More sharing options...
Ress Posted May 2, 2022 Share Posted May 2, 2022 What hook are you using? Link to comment Share on other sites More sharing options...
sphway Posted May 2, 2022 Author Share Posted May 2, 2022 37 minutes ago, Ress said: What hook are you using? i'm using displayBackOfficeHeader displayHeader displayOrderConfirmation Link to comment Share on other sites More sharing options...
sphway Posted May 2, 2022 Author Share Posted May 2, 2022 3 hours ago, abdullacm said: did you try the way as endriu107 suggested, and did you see these variables inside the debug popup ? I didn't see anything Link to comment Share on other sites More sharing options...
abdullacm Posted May 2, 2022 Share Posted May 2, 2022 17 minutes ago, sphway said: I didn't see anything put {debug} in your tpl file as in the screenshot, then a popup opens with details of all the variables available in the tpl (open as new window, will ask for permission first time) Link to comment Share on other sites More sharing options...
endriu107 Posted May 2, 2022 Share Posted May 2, 2022 Maybe your browser didn't allow to show popup... 14 hours ago, sphway said: Thanks for your reply,I debug the {$urls.current_url} and {$page_name},they are all null {$page_name} is incorrect it should be {$page.page_name} 1 Link to comment Share on other sites More sharing options...
sphway Posted May 2, 2022 Author Share Posted May 2, 2022 12 minutes ago, abdullacm said: put {debug} in your tpl file as in the screenshot, then a popup opens with details of all the variables available in the tpl (open as new window, will ask for permission first time) I add {debug} in my tpl file,there is no $urls.current_url and $page_name Link to comment Share on other sites More sharing options...
sphway Posted May 2, 2022 Author Share Posted May 2, 2022 11 minutes ago, endriu107 said: Maybe your browser didn't allow to show popup... {$page_name} is incorrect it should be {$page.page_name} I tried {$page.page_name},still no luck Link to comment Share on other sites More sharing options...
abdullacm Posted May 2, 2022 Share Posted May 2, 2022 try this in your tpl {Context::getContext()->controller->php_self} Link to comment Share on other sites More sharing options...
sphway Posted May 3, 2022 Author Share Posted May 3, 2022 (edited) 20 hours ago, abdullacm said: try this in your tpl {Context::getContext()->controller->php_self} I add the code in my php file $context->smarty->assign(array( 'all_var' => Context::getContext() )); but no $current_url and $page_name in the debug popup Edited May 3, 2022 by sphway (see edit history) Link to comment Share on other sites More sharing options...
abdullacm Posted May 3, 2022 Share Posted May 3, 2022 On 5/2/2022 at 4:08 PM, abdullacm said: try this in your tpl {Context::getContext()->controller->php_self} did you try this in your tpl file? 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