Closed parinisantiago closed 7 years ago
I install codeigniter-ss-twig and twig with Composer. Also I call a controller from another controller. My Class herarchy look something like this:
class MainController extends Controller
{
public function __construct()
{
parent::__construct();
}
public function index()
{
if(Session::userLogged())
{
$this->controller= new BackendController();
$this->controller->index();
} else {
$this->render('MainTemplate');
}
}
}
class BackendController extends Controller{
public function __construct(){
parent::__construct();
}
public function index(){
$this->render('BackendTemplate');
}
}
class Controller extends CI_controller
{
protected $data;
protected function __construct(){
parent::__construct();
}
protected function render($view){
$this->load->library('twig');
$this->twig->display($view,$this->data);
}
My default controller is MainController, when this controller is called for first time it's works fine but then when I make a call to another controller i get that error.
This is because of CodeIgniter's specification. That is you can't call another controller from a controller.
This reply is wrong. In Codeigniter you can call one controller from another controller. This does not work only because of twig. There is something wrong in the twig integration with Hmvc.
In Codeigniter you can call one controller from another controller.
You could call, but CI does not work like what you want. See https://stackoverflow.com/questions/14165895/how-to-load-a-controller-from-another-controller-in-codeigniter.
In Codeigniter you can call one controller from another controller.
You could call, but CI does not work like what you want. See https://stackoverflow.com/questions/14165895/how-to-load-a-controller-from-another-controller-in-codeigniter.
The stackoverflow link you have given is dated 4 years or older. I am using PHP 7, CI 3.1.11 and HMVC revamp and Twig 2.0 and these solutions dont fit. Anyway i fixed it already. I used the CI "redirect" function and "flashdata" combination instead. This works fine. I have attached the modules here:
Hi @kenjis,
I installed codeigniter-ss-twig and work very well, but for some reason I get this error:
Fatal error: Class 'CI_Twig' not found in /path/to/codeigniter/system/core/Common.php on line 196
Here it's a screenshot of the problem:
it's related to the librarie? Any help?