Welcome Guest, Not a member yet? Register   Sign In
include view in parser
#7

(01-09-2019, 01:34 AM)Pertti Wrote: Ah, so you are using new templating engine? https://codeigniter4.github.io/CodeIgnit...arser.html

I guess it depends on what kind of PHP code you want to put in your view file, but it probably shouldn't do anything beyond IF checks, which you can do in templating engine:
Code:
{if $role=='admin'}
       <h1>Welcome, Admin</h1>
{elseif $role=='moderator'}
       <h1>Welcome, Moderator</h1>
{else}
       <h1>Welcome, User</h1>
{endif}

You should do everything else on Controller or Model side, so view itself shouldn't try to go and figure things out, it should be just - here's data to render, here#s maybe slightly different layout or styling if some conditions are met.
Ok thanks, but I guess I will use my own plugin to include template inside a template. It replaced old code like
PHP Code:
<?php $this->view('viewfile) ?> with {+ include Path\To\template +} 

And it works well Smile
Reply


Messages In This Thread
include view in parser - by adnzaki - 01-01-2019, 11:27 PM
RE: include view in parser - by Pertti - 01-02-2019, 02:00 AM
RE: include view in parser - by adnzaki - 01-08-2019, 08:30 PM
RE: include view in parser - by puschie - 01-02-2019, 05:09 AM
RE: include view in parser - by adnzaki - 01-08-2019, 08:34 PM
RE: include view in parser - by Pertti - 01-09-2019, 01:34 AM
RE: include view in parser - by adnzaki - 01-09-2019, 08:45 PM
RE: include view in parser - by kilishan - 04-23-2019, 06:39 AM
RE: include view in parser - by adnzaki - 04-20-2020, 09:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB