Welcome Guest, Not a member yet? Register   Sign In
Twig integration in CI4
#19

(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) %}

&lt;div class=&quot;linklist-paging&quot;&gt;
    &lt;div class=&quot;paging pure-g&quot;&gt;
        &lt;div class=&quot;linklist-pages pure-u-1-3&quot;&gt;
[..]
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
Reply


Messages In This Thread
Twig integration in CI4 - by murugappan - 06-06-2020, 06:23 PM
RE: Twig integration in CI4 - by jreklund - 06-07-2020, 01:14 AM
RE: Twig integration in CI4 - by ivantcholakov - 06-07-2020, 04:54 AM
RE: Twig integration in CI4 - by murugappan - 06-07-2020, 03:02 PM
RE: Twig integration in CI4 - by jreklund - 06-08-2020, 10:50 AM
RE: Twig integration in CI4 - by murugappan - 06-09-2020, 06:30 AM
RE: Twig integration in CI4 - by Marcos Queiroz - 05-04-2021, 11:57 AM
RE: Twig integration in CI4 - by daycry - 05-11-2021, 05:41 AM
RE: Twig integration in CI4 - by kai_lf - 11-05-2021, 09:14 AM
RE: Twig integration in CI4 - by kenjis - 03-20-2023, 01:10 AM
RE: Twig integration in CI4 - by foxbille - 04-07-2023, 09:22 AM
RE: Twig integration in CI4 - by filipussetio - 04-27-2023, 09:22 AM
RE: Twig integration in CI4 - by foxbille - 08-23-2023, 07:44 AM
RE: Twig integration in CI4 - by murugappan - 03-20-2023, 01:48 AM
RE: Twig integration in CI4 - by kenjis - 04-07-2023, 06:37 PM
RE: Twig integration in CI4 - by foxbille - 04-08-2023, 11:56 AM
RE: Twig integration in CI4 - by kenjis - 04-08-2023, 04:59 PM
RE: Twig integration in CI4 - by foxbille - 04-12-2023, 02:05 AM
RE: Twig integration in CI4 - by kenjis - 04-12-2023, 05:26 AM
RE: Twig integration in CI4 - by foxbille - 04-14-2023, 02:43 AM
RE: Twig integration in CI4 - by kenjis - 04-14-2023, 03:17 AM
RE: Twig integration in CI4 - by kenjis - 04-14-2023, 03:26 AM
RE: Twig integration in CI4 - by foxbille - 04-17-2023, 04:55 AM
RE: Twig integration in CI4 - by ozornick - 08-23-2023, 07:55 AM
RE: Twig integration in CI4 - by foxbille - 08-23-2023, 09:45 AM
RE: Twig integration in CI4 - by ozornick - 08-23-2023, 09:56 AM
RE: Twig integration in CI4 - by foxbille - 08-24-2023, 07:13 AM
RE: Twig integration in CI4 - by kenjis - 08-24-2023, 05:05 PM
RE: Twig integration in CI4 - by foxbille - 09-02-2023, 09:37 AM
RE: Twig integration in CI4 - by ALTITUDE_DEV - 12-29-2023, 04:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB