Jump to content

Creating controller


gudule1er

Recommended Posts

Hello there, 
 
I watched lots of tutorials and no way to create a controller that works ... 
 
I'm version 1.6 
 
I tell you what I did ...
 
at the root of my site I created a page that contains Compatibilite.php
require_once(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/header.php');
Tools::displayFileAsDeprecated();

Tools::redirect('index.php?controller=Compatibilite'.($_REQUEST ? '&'.http_build_query($_REQUEST, '', '&') : ''), __PS_BASE_URI__, null, 'HTTP/1.1 301 Moved Permanently')

Then in the wicker controller I created a file that contains CompatibiliteController.php

class CompatibiliteController extends FrontController
{
  
		public $php_self = 'Compatibilite';
		public $ssl=true;

  public function initContent()
  {
  
   parent::initContent();
   $req_sortie=Db::getInstance()->ExecuteS('select id_feature_value from '._DB_PREFIX_.'feature_value where id_feature=11');
	
 
  $this->context->smarty->assign('req_sortie',$req_sortie);
  
   $this->setTemplate(_PS_THEME_DIR_.'Compatibilite.tpl');
  }
 
}

and finally in the record of my theme I created a file that contains Compatibilite.tpl

<pre>
    {$req_sortie|var_dump}
</pre>
just to see if my application works ... 
 
but when I call the URL https://monsite.com/...r=Compatibilite I get the following message:
 
Fatal error: Class 'Compatibilite' not found in /home/monsite/www/classes/controller/Controller.php on line 135
 
I don't understand... 
 
any idea? 
 
thank you
 
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...