thephpleague / plates

Native PHP template system
https://platesphp.com
MIT License
1.48k stars 180 forks source link

Conflict with $this->session->userdata() codeigniter - plates #158

Closed adolfoamaris closed 6 years ago

adolfoamaris commented 7 years ago

Hello, I implemented plates in codeigniter 3 and I have a conflict when trying to echo $ this-> session-> userdata ("username"); with the following message:

How could I solve it?

A PHP Error was encountered

Severity: Notice

Message: Undefined property: League\Plates\Template\Template::$session

Filename: views/main.php

Line Number: 202

Thank you

ragboyjr commented 7 years ago

$this is a reference to the Plates Template i believe, and not the CI super global. you'll need to do something like get_instance()->session or pass in the CI object as a global to the Plates Engine.

ipranjal commented 7 years ago

CI_Controller is the superglobal used in CI to get instances if session etc. In extension to @ragboyjr's answer

ragboyjr commented 7 years ago

@adolfoamaris can we close this?