(04-12-2023, 05:26 AM)kenjis Wrote: 1. The DEBUG-VIEW comment like "<!-- DEBUG-VIEW START 1 APPPATH/Views/Pager/default_full.php -->" is output by CI4's View class.
2. If you use Pagination in CI4 with Twig, the DEBUG-VIEW comment will be output in the output HTML.
3. To disable it, set the CI_DEBUG constant to false.
Ok, thanks for the explanation, that's what i had found using {{ dump(pager.links) }} to understand
But i can't fix it!
I put CI_DEBUG = false in .ENV but it does not work for twig
Even for classic codeigniter view mode (this below is part of the html flow) :
Code:
<!-- DEBUG-VIEW START 1 APPPATH/Views/pagers/default_full.php -->
Only CI_ENVIRONMENT = development can remove "DEBUG-VIEW"
But then, using twig, the flow is still not good, code of default_full.twig is displayed as if htmlentities() was used
Code:
[..]
</div>
{% pager.setSurroundCount(2) %}
<div class="linklist-paging">
<div class="paging pure-g">
<div class="linklist-pages pure-u-1-3">
[..]
This is my code :
In app\Config\Pager.php
PHP Code:
public array $templates = [
'default_full' => 'App\Views\pagers\default_full.twig',
in app\Controller\Bookmark.php
PHP Code:
public function initController(
\CodeIgniter\HTTP\RequestInterface $request,
\CodeIgniter\HTTP\ResponseInterface $response,
\Psr\Log\LoggerInterface $logger
) {
parent::initController($request, $response, $logger);
$this->bookmarkModel = new bookmarkModel();
$this->tagModel = new tagModel();
$this->twig = new \Kenjis\CI4Twig\Twig(['functions' => ['dateSlash','pager'],]);
}
public funtion index()
{
$conf = new \Config\Pager();
$pager = \Config\Services::pager();
$bookmarks = $this->bookmarkModel->findAll();
$tags = $this->tagModel->findAll();
$data = [
'bookmarks' => $bookmarks,
'tags' => $tags,
'pager' => $this->bookmarkModel->pager,
];
return $this->twig->render('bookmark/index',$data);
}
in Views\Bookmark\index.twig
PHP Code:
{% extends "default.twig" %}
{% block content %}
{% if pager is defined %}
{{ pager.links }}
{% endif %}
in app\Views\default.twig
PHP Code:
<main id="content" class="container" role="main">
{{ include('menu.twig') }}
{{ include('header.twig') }}
{% block content %}{% endblock %}
{{ include('footer.twig') }}
</main>