Welcome Guest, Not a member yet? Register   Sign In
twig and view cell
#1

Hi all,
When i try to use view cells and twig i get this error
Twig\Error\SyntaxError
The arrow function argument must be a list of variables or a single variable in "blog/index.twig" at line 15
at line
Code:
<li class="list-inline-item">Tags : {{ view_cell('App\Cells\TagsCell::getOne',['article_id' => article.id ]) }}</li>
Does someone can help ?
Thanks
Eric
Reply
#2

I modified my view like this :
Code:
{% set params = {'article_id': article.id} %}
<li class="list-inline-item">Tags : {{ view_cell('App\Cells\TagsCell::getOne', params) }}</li>

Added /app/Helpers/view_cell.php, copied from /vendor/codeigniter4/framework/system/Common.php lines 1177-1191

Attached helper to twig call in controller:
Code:
$twig = new \Kenjis\CI4Twig\Twig(['functions' => ['view_cell']]);
return $twig->render('blog/index', ['articles' => $articles, 'tags' => 'whatever...', 'title' => 'Liste des articles']);
Now got new error
Code:
Twig\Error\RuntimeError
An exception has been thrown during the rendering of a template ("Impossible de localiser la class view cell: AppCellsTagsCell.") in "blog/index.twig" at line 16
Meaning "cannot locate class" /App/Cells/TagsCell
Reply




Theme © iAndrew 2016 - Forum software by © MyBB