Jump to content

Override Identity Controller


Claudiu Nesa

Recommended Posts

Hello,

 

I'm trying to override the identity controller from the Prestashop core in order to add some things that are related to a module that i'm making!

 

I'm doing everything as it is described in the new documentation for Prestashop 1.5 but yet no result!

 

If there is somebody who encountered this kind of issue and is willing to help me please do it :)!

 

Thank you in advance!

 

Here is my code:

 class IdentityController extends IdentityControllerCore
{

 public function init() {

		parent::init();

  require_once($this->module->getLocalPath().'Post.php');
  require_once($this->module->getLocalPath().'Comment.php');
	}

 public function initContent()
 {
  parent::initContent();

  if (!Context::getContext()->customer->isLogged())
		 Tools::redirect('index.php?controller=auth&redirect=module&module=shareproduct&action=post');

  // $this->context->smarty->assign('dummys','it works');
  self::$smarty->assign('dummys','it works');

  // $this->setTemplate(_PS_MODULE_DIR_.'shareproduct/views/templates/hook/identity.tpl');
  $this->setTemplate('shareproduct-identity.tpl');
 }

 public function displayContent()
 {

  return $this->display(_PS_MODULE_DIR_.'shareproduct/views/templates/front/shareproduct-identity.tpl');
 }
}

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

 

 

And if you add

public function run(){

parent::run()

}

Does this solve the problem ?

 

My first attempt to find the problem was bad.

Put your code (at least the 'redirect' part) in the init section.

Redirect and cookies processing are ok in the preprocess() and must be ok also in ini(), but in initContent() it must be 'to late' (before screen output).

 

Good luck

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

  • 4 weeks later...

Hi,

 

 

 

 

My first attempt to find the problem was bad.

Put your code (at least the 'redirect' part) in the init section.

Redirect and cookies processing are ok in the preprocess() and must be ok also in ini(), but in initContent() it must be 'to late' (before screen output).

 

Good luck

Thank you for your advice I'll try to do as you said and i hope it'll work :)

perhaps you could describe what you are trying to do in the code? Also, what version of prestashop are you using. You mentioned you are following a v1.5 guide, but are you using v1.5?

I'm developing some modules on Prestashop 1.5 RC (to be more specific I'm using PS 1.5.0.14). I want to add some kind of posts feed on the Personal Information page which is controlled by IdentityController. I don't want to change it's current design or functionality only to add that posts feed :)! If you need some other input please let me know!

 

Thank you both!

 

Cheers,

C.

Link to comment
Share on other sites

i would start by adding some simple echo statements to each of your functions in the overriden controller. let's first confirm that your functions are even being executed.

 

for example, i would do the following

public function init() {
   echo "my init called<br>";
   parent::init();
   echo "parent init called<br>";

   require_once($this->module->getLocalPath().'Post.php');
   echo "included post.php<br>";
   require_once($this->module->getLocalPath().'Comment.php');
   echo "included Comment.php<br>";
}

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...