Jump to content

Can't add CustomController


UsrNems

Recommended Posts

Hi,

 

I'm getting trouble with my Presta.

 

I've been looking all afternoon long for an answer and I've found many of them.

 

So, here it is :

 

First ! I've made a custom.php in / and set permisssions to 644

<?php

require(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated();
Tools::redirect('index.php?controller=custom'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently');

Second ! I've made a CustomController in /controller/front/CustomController.php and set permissions to 644

<?php                                                                                           

class CustomControllerCore extends FrontController
{
	public $php_self = 'custom';

	public function initContent()
	{
		parent::initContent();
		$this->setTemplate(_PS_THEME_DIR_.'custom.tpl');
	}
}

?>

Third ! For sure I've build a wonderful custom.tpl in /theme/personalTheme/custom.tpl and set permission to 604

<h1>MY WONDERFUL CUSTOM PAGE</h1>

Fourth ! Came in to : /cache and deleted class_index.php

 

Fifth ! Came in to /cache/smarty and deleted everything except index.php

 

Six ! In my website's backoffice, I've been through SEO and added a new link: custom

 

Seven ! In my website's backoffice, I've been through performances, and clear cache (And everything in this page has been turned to off)

 

Eight ! Clear my browser cache

 

Nine ! Killing myself with my mouse

And after all these steps i'm still getting this error when i'm trying to go to : mywebsite.com/custom

 

 

 

Fatal error: Class 'CustomController' not found in /home/geremesfcz/www/web/classes/controller/Controller.php on line 135

 

Oh I forgot, I also tried this : https://www.prestashop.com/forums/topic/250826-adding-a-new-page-controller-issue/?do=findComment&comment=1542578

 

Still this issue :'(

 

Can you remove that gun off my head ? That would be great !

Thanks a lot !

 

 

P.S : I'm using Prestashop 1.6.0.11

  • Like 1
Link to comment
Share on other sites

I suppose your class should be named CustomController instead of CustomControllerCore.  You still have to put it in the /override folder and delete class_index.php

 

Hi Simone !

 

Sadly I just tried this but it won't work. I tried with both CustomController & CustomControllerCore :/

Link to comment
Share on other sites

If you open class_index.php, do you find a record about your CustomController? If it exists, it shows where your class is. If it doesn't exists, there's a problem locating your file.

 

No he doesn't find it :/

 

When I manually enter my class in this file, it work, but everytime it's recompiled it fly away :'(

Link to comment
Share on other sites

This is all I can say:

 1) make sure you put your CustomController.php file in /override/controllers/front folder

 2) check you spelled correctly the class name and the file name

 3) delete the closing ?> tag in the controller file (I read once it can cause troubles)

 

I have several overrides in my shop (all AdminControllers, though) and they all work with no problem.

You can also try making another override, maybe an Admin one, and see if this works (so you know it's a problem with ALL overrides or just that one)

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

This is all I can say:

 1) make sure you put your CustomController.php file in /override/controllers/front folder

 2) check you spelled correctly the class name and the file name

 3) delete the closing ?> tag in the controller file (I read once it can cause troubles)

 

I have several overrides in my shop (all AdminControllers, though) and they all work with no problem.

You can also try making another override, maybe an Admin one, and see if this works (so you know it's a problem with ALL overrides or just that one)

 

Hi Simone and thanks again for your help.

 

I tried removing the ?>, I didn't knew that it was causing troubles. But still no result.

 

I'm always getting this error :/

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