Welcome Guest, Not a member yet? Register   Sign In
Templates in CI version 4
#2

(This post was last modified: 11-24-2019, 04:50 AM by InsiteFX.)

You can do it almost the same way.

Add your template method to the CI 4 BaseController.

Then extend all your controllers from the BaseController.

I tested it here and it worked fine.

BaseController:

PHP Code:
    public function template(string $page, array $data)
    {
        echo view('templates/v1/header'$data);
        echo view($page$data);
        echo view('templates/v1/footer'$data);
    

Then call it like this:

PHP Code:
$this->template('auth/login, $data); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
Templates in CI version 4 - by zye - 11-23-2019, 10:24 AM
RE: Templates in CI version 4 - by InsiteFX - 11-24-2019, 04:48 AM
RE: Templates in CI version 4 - by dave friend - 11-24-2019, 07:14 AM
RE: Templates in CI version 4 - by zye - 11-24-2019, 05:08 PM



Theme © iAndrew 2016 - Forum software by © MyBB