Jump to content

[SOLVED] PS_SHOP_DOMAIN in all Modules


stratboy

Recommended Posts

Hi. I'd like to find a way to let all the Modules know PS_SHOP_DOMAIN. In other words, a way to make a smarty variable with PS_SHOP_DOMAIN value be available for all modules.

 

I thought I could extend the ModuleCore class, but being it an abstract class I'm not really sure, and also I don't know in what method I should assign the smarty var.

 

Any suggestion?

Edited by stratboy (see edit history)
Link to comment
Share on other sites

Done by overriding FrontController::init(). Here's the code:

 

Class FrontController extends FrontControllerCore{
  public function init(){
 parent::init();
 $this->context->smarty->assign('shop_domain', Configuration::get('PS_SHOP_DOMAIN'));
  }

  public function initContent(){
  //here you can eventually assign other things like custom hooks (I often do it). But init() is the right place to add 'global' smarty variables.
 parent::initContent();
  }
}

 

This way $shop_domain will be available not only for every module in every hook, but more generally to all front-end .tpl files.

 

Hope it helps

Edited by stratboy (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...