Jump to content

[solved] [1.5.4] Can't override FrontController


stratboy

Recommended Posts

I know there are similar questions, but none of them can solve my problem.

 

I placed a FrontController.php file in /override/classes/controller/

 

It contains this code:

 

	Class FrontController extends FrontControllerCore{
	public function displayHeader(){
		if(!self::$initialized) $this->init();

		$this->context->smarty->assign('test_ok','okok');

		return parent::displayHeader();	  
	}
}//end FrontController

 

 

From my custom theme, in header.tpl I placed a test code like this

 

	{$test_ok}

 

And get this:

 

Notice: Undefined index: test_ok in [...]/cache/smarty/compile/81/a3/76/81a3760f9c0cb8c9ff677a0e7b59d8962cdaaeda.file.header.tpl.php on line 147

 

Notice: Trying to get property of non-object in [...]/cache/smarty/compile/81/a3/76/81a3760f9c0cb8c9ff677a0e7b59d8962cdaaeda.file.header.tpl.php on line 147

 

---

 

I also tried to assign that smarty var directly in FrontControllerCore.php (only just to test) but got the same notice.

 

...And of course tried to clean class_index and all the smarty cache

 

---

 

UPDATE: I succeeded in get the ovverride recognized, meaning that now I can read this in class_index:

'FrontController' => 'override/classes/controller/FrontController.php', 'FrontControllerCore' => 'classes/controller/FrontController.php'

,

 

NEW UPDATE: I can see the smarty variable IF I assign it in initHeader() INSTEAD of displayHeader() or init().

 

Why can't I use that 2 methods? Isn't quite strange? Can someone explain the mechanics of this behaviour?

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

It appers to be a cache problem,

 

In the performance options choose the option "force compilation" for templates and deactivate cache too.

 

Hi, done, but it didn't work.

 

Anyway, someway, now as I wrote I have the override recognized. And, NEW UPDATE: I can see the smarty variable IF I assign it in initHeader() INSTEAD of displayHeader() or init().

 

Why doesn't it work in displayHeader() or init()?

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