lmikula Posted April 17, 2015 Share Posted April 17, 2015 Hello, where would be the best way to place code to add custom response header to all front pages ? Currently I do it in: override/controllers/FrontController.php Where i override the initHeader() function like this: public function initHeader() { parent::initHeader(); if ($this->context->customer->isLogged()) { /** some more logic **/ header('X-PS-CustomHeader: some_value'); } } It works as expected (at least from a brief test)... My question is: Is this the right procedure or is there a better/more appropriate way to achieve this ? Link to comment Share on other sites More sharing options...
Tuni-Soft Posted April 18, 2015 Share Posted April 18, 2015 Check the method Tools::redirect, you will find that PrestaShop uses the same technique, nothing special (check the code after // Send additional headers) Link to comment Share on other sites More sharing options...
lmikula Posted April 18, 2015 Author Share Posted April 18, 2015 Well i meant not the header function itself, but whether it's along with the best practice and coding standards in PS (I mean the placement of that code) Link to comment Share on other sites More sharing options...
Tuni-Soft Posted April 18, 2015 Share Posted April 18, 2015 Yes, check the method FrontController::initHeader 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