widepresta Posted March 15, 2017 Share Posted March 15, 2017 (edited) How identify in php class module current url page? $this->context->controller->php_self Work on all page but not my custom front page There were similar problems? Edited March 15, 2017 by widepresta (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted March 15, 2017 Share Posted March 15, 2017 Does that not work in 1.7? Looking at the code, php_self is still defined Link to comment Share on other sites More sharing options...
widepresta Posted March 15, 2017 Author Share Posted March 15, 2017 (edited) Does that not work in 1.7? Looking at the code, php_self is still defined $this->context->controller->php_self Work on home page, category page, product page and other. It for some reason will not work on my page. How do I know if this is my page? Edited March 15, 2017 by widepresta (see edit history) Link to comment Share on other sites More sharing options...
widepresta Posted March 15, 2017 Author Share Posted March 15, 2017 Two variant identify page Dispatcher::getInstance()->getController() or Tools::getValue('controller') Link to comment Share on other sites More sharing options...
bellini13 Posted March 15, 2017 Share Posted March 15, 2017 can you better describe what "your page" is? what did you create? Link to comment Share on other sites More sharing options...
widepresta Posted March 15, 2017 Author Share Posted March 15, 2017 can you better describe what "your page" is? what did you create? Create class class MymoduleCollectionModuleFrontController extends ModuleFrontController { public function initContent() { parent::initContent(); $this->context = Context::getContext(); $this->setTemplate('module:mymodule/views/templates/front/collection.tpl'); } } Link to comment Share on other sites More sharing options...
Cher Posted March 15, 2017 Share Posted March 15, 2017 Hello, I have same issue with Tools::getValue(), it always give back NULL. in my case i call it from hookActionProductUpdate(), where i have extra text field on BO displayAdminProductsExtra.tpl Link to comment Share on other sites More sharing options...
bellini13 Posted March 16, 2017 Share Posted March 16, 2017 Create class class MymoduleCollectionModuleFrontController extends ModuleFrontController { public function initContent() { parent::initContent(); $this->context = Context::getContext(); $this->setTemplate('module:mymodule/views/templates/front/collection.tpl'); } } you never set the php_self variable. If you look at all of the core front controllers (like ProductController), they are set their page names. 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