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

(This post was last modified: 01-08-2019, 08:39 PM by adnzaki.)

Hi, I'm so excited with brand new template parser in CI4. But I got a problem when including file directly in template, because in CI3 I used to use this simple code to include view inside a view
Code:
$this->view()
In CI4's parser, (as we know) we cannot write any PHP code inside a template, so I added a plugin to include another view.
The question, is there a way in parser for including view directly? If not, it would be great if CI4's parser comes with functionality to include file directly (nested view).
And here is plugin I added to parser:
PHP Code:
public static function include(array $params = [])
{
    $parser = \Config\Services::parser();
    return $parser->render(...$params);
}

// register plugin in Config/View.php
public $plugins = [
    'include' => '\Actudent\Core\Config\ActudentParserPlugin::include',
];

// call it in view 
{+ include Actudent\Core\Views\component\head +} 

Thanks CI4 team!
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