PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, January 11, 2022

[FIXED] How to create template for cakephp paginator?

 January 11, 2022     cakephp, cakephp-4.x, pagination     No comments   

Issue

I am trying to apply bootstrap 4 pagination style in cakephp paginator helper.

It is looking very hard to me.

This my simple html that I want to apply in paginator helper

<nav aria-label="Page navigation example">
  <ul class="pagination">
    <li class="page-item"><a class="page-link" href="#">Previous</a></li>
    <li class="page-item"><a class="page-link" href="#">1</a></li>
    <li class="page-item"><a class="page-link" href="#">2</a></li>
    <li class="page-item"><a class="page-link" href="#">3</a></li>
    <li class="page-item"><a class="page-link" href="#">Next</a></li>
  </ul>
</nav>

I created a paginator-templates file in config location.

config/paginator-templates.php

return [
    'number' => '<a href="{{url}}">{{text}}</a>',
];

Then I have initialized in appView.php

public function initialize(): void
{
       $this->loadHelper('Paginator', ['templates' => 'paginator-templates']);
}

After that getting below error

Config file "paginator-templates.php" did not return an array

How can I create a paginator-templates.php for apply bootstrap 4 pagination design in cakephp ? Has there any blog or example ?


Solution

What is the file returning?

One way to work around this might be to use the setTemplate() method on the helper.

https://book.cakephp.org/3/en/views/helpers/paginator.html#changing-templates-at-run-time

Using your supplied example code I've been able to get the code working in Cake 3.8.5

I wonder if you just forgot the opening <?php tag in your templates file so it's coming back as a string.



Answered By - Don Drake
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing