Jump to content

Get current page name or current urls in my module


sphway

Recommended Posts

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

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

e2.jpg

e1.jpg

Link to comment
Share on other sites

10 hours ago, sphway said:

Thanks for your reply,I debug the {$urls.current_url} and {$page_name},they are all null

 

e2.jpg

e1.jpg

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

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)

Screenshot 2022-05-02 at 1.37.00 PM.png

Screenshot 2022-05-02 at 1.37.21 PM.png

Link to comment
Share on other sites

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}

  • Like 1
Link to comment
Share on other sites

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

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

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 by sphway (see edit history)
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...