Hi,
I face a problem with a class scaffolded with the devtools : the class is called "page" and in my volt search result view, I cannot access "page.total_pages".
<?php
namespace Application\Cms\Controllers;
use Phalcon\Mvc\Model\Criteria,
Phalcon\Paginator\Adapter\Model as Paginator,
Cocur\Slugify\Slugify as Slugify,
Application\Cms\Models\Page as Page;
class PageController extends ControllerBase
{
public function searchAction()
{
$numberPage = 1;
if ($this->request->isPost()) {
$query = Criteria::fromInput($this->di, Page::class, $_POST);
$this->persistent->parameters = $query->getParams();
} else {
$numberPage = $this->request->getQuery("page", "int");
}
$parameters = $this->persistent->parameters;
if (!is_array($parameters)) {
$parameters = array();
}
$parameters["order"] = "id";
$page = Page::find($parameters);
if (count($page) == 0) {
$this->flash->notice("The search did not find any page");
$this->dispatcher->forward(array(
"controller" => "page",
"action" => "index"
));
return;
}
$paginator = new Paginator(array(
'data' => $page,
'limit'=> 10,
'page' => $numberPage
));
$this->view->page = $paginator->getPaginate();
}
}
Up until here, I can access $paginator->get_paginate()->total_pages
<div class="page-header">
<h1>Search result</h1>
</div>
{{ content() }}
<div class="row">
<table class="table table-bordered">
<thead>
<tr>
<th>Id</th>
<th>Title</th>
<th>Slug</th>
<th>Body</th>
<th>Date Of Create</th>
<th>Date Of Publish</th>
<th>Published</th>
<th>Tracked</th>
<th>Id Of Category</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
{% if page.items is defined %}
{% for page in page.items %}
<tr>
<td>{{ page.getId() }}</td>
<td>{{ page.getTitle() }}</td>
<td>{{ page.getSlug() }}</td>
<td>{{ page.getBody() }}</td>
<td>{{ page.getDateCreate() }}</td>
<td>{{ page.getDatePublish() }}</td>
<td>{{ page.getPublished() }}</td>
<td>{{ page.getTracked() }}</td>
<td>{{ page.getIdCategory() }}</td>
<td>{{ link_to("page/edit/"~page.getId(), "Edit") }}</td>
<td>{{ link_to("page/delete/"~page.getId(), "Delete") }}</td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
</div>
<div class="row">
<div class="col-sm-1">
<p class="pagination" style="line-height: 1.42857;padding: 6px 12px;">
{{ page.current~"/"~page.total_pages }}
</p>
</div>
<div class="col-sm-11">
<nav>
<ul class="pagination">
<li>{{ link_to("page/search", "First") }}</li>
<li>{{ link_to("page/search?page="~page.before, "Previous") }}</li>
<li>{{ link_to("page/search?page="~page.next, "Next") }}</li>
<li>{{ link_to("page/search?page="~page.last, "Last") }}</li>
</ul>
</nav>
</div>
</div>
But here, I can access {{ page.total_pages }}
BEFORE the table, but not AFTER. I suspect the class name "page" to be responsible, but I cannot figure out how to debug this without changing the name of the class (which I do not want).
Can someone point my mistake ?
Thanks in advance for any help.