trouille2 Posted January 23, 2015 Share Posted January 23, 2015 Hello everybody, I'm trying to create a module that will show a fullscreen slideshow on the home page and a fullscreen background image (no slideshow) on other pages based on category thumbnail. For the homepage, I use supersize jquery. It seems the supersize js file, when declared, create some divs and a preview wheel appears on every page. I would like to prevent this by declaring the supersize js file only on the homepage. So on the module root folder, I have my_module.php file in which I declare my js files in : public function hookDisplayHeader() I'd like to add a condition like if($page_name == 'index')... You see what I need. $page_name is a Smarty variable...How to get the same but for php? Chris Link to comment Share on other sites More sharing options...
Krystian Podemski Posted January 23, 2015 Share Posted January 23, 2015 Maybe: if (isset($this->context->controller->php_self) && $this->context->controller->php_self == 'index') 1 1 Link to comment Share on other sites More sharing options...
bellini13 Posted January 23, 2015 Share Posted January 23, 2015 You don't say what version of Prestashop you need to support with this module, and PS v1.4 would likely work different than v1.5 or 1.6. So I can give you some pointers to play with You can try looking at the value of the controller if (Tools::getValue('controller') == 'index') Alternatively, you could check the value of 'PHP_SELF' which should be the full path to the PHP file. Then apply comparison logic once you figure out what the path is $_SERVER['PHP_SELF'] Link to comment Share on other sites More sharing options...
trouille2 Posted January 23, 2015 Author Share Posted January 23, 2015 Krystian, It was it. Thanks a lot. Link to comment Share on other sites More sharing options...
polcoder Posted May 20, 2015 Share Posted May 20, 2015 (edited) Or this one: $this->page_name = Dispatcher::getInstance()->getController(); if ($this->page_name == 'index') { ... } Edited May 20, 2015 by polcoder (see edit history) 2 Link to comment Share on other sites More sharing options...
baonk Posted March 10, 2017 Share Posted March 10, 2017 I have found a snippet in FrontController.php how to get page name if (!empty($this->page_name)) { $page_name = $this->page_name; } elseif (!empty($this->php_self)) { $page_name = $this->php_self; } elseif (Tools::getValue('fc') == 'module' && $module_name != '' && (Module::getInstanceByName($module_name) instanceof PaymentModule)) { $page_name = 'module-payment-submit'; } // @retrocompatibility Are we in a module ? elseif (preg_match('#^'.preg_quote($this->context->shop->physical_uri, '#').'modules/([a-zA-Z0-9_-]+?)/(.*)$#', $_SERVER['REQUEST_URI'], $m)) { $page_name = 'module-'.$m[1].'-'.str_replace(array('.php', '/'), array('', '-'), $m[2]); } else { $page_name = Dispatcher::getInstance()->getController(); $page_name = (preg_match('/^[0-9]/', $page_name) ? 'page_'.$page_name : $page_name); } 2 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