Gleez sub-page function optimization
When a method in a controller only calls the paging function, and in the index method, there is no need for the following optimization, otherwise it can be optimized according to the proposed content;
Locate the URL method under the/modules/gleez/classes/gleez/pagination.php file, and modify the contents to see the red font
Public Function url ($page = 1)
{
Clean the page number
$page = max (1, (int) $page);
Gleez CMS pagination
$pager = '/P '. $page;
No page number in URLs to first page
if ($page = = = 1 and! $this->config[' First_page_in_url '))
{
$page = NULL;
$pager = NULL;
}
Switch ($this->config[' current_page ' [' Source '])
{
Case ' query_string ':
Return Url::site ($this->_route->uri ($this->_route_params).
$this->query (Array ($this->config[' current_page ' [' key '] = + $page) ));
When paging is invoked, the query page is incremented directly in the URL link, otherwise the URL displayed defaults to the method of the controller's index, and the query pages are incremented (and the URL omits the index method name display)
if ($this->_uri) {
Return Url::site ($this->_uri.
$this->query (Array ($this->config[' current_page ' [' key '] = + $page)));
}else{
Return Url::site ($this->_route->uri ($this->_route_params).
$this->query (Array ($this->config[' current_page ' [' key '] = + $page)));
}
Case ' route ':
Return Url::site ($this->_route->uri (
Array_merge (
$this->_route_params,
Array ($this->config[' current_page ' [' key '] = + $page)
)
). $this->query ());
Case ' CMS ':
Return Url::site ($this->_uri. $pager. $this->query ());
}
Return ' # ';
}
The method of invoking paging function in the Controller method is as follows:
Public Function Action_select ()
{
$this->title = __ (' paged test ');
$sql _p = "SELECT * FROM Products";
$p _values = Db::query (Database::select, $sql _p)
->execute ()
->as_array ();
Calculate the total query record
$count = count ($p _values);
Page out
$pagination = pagination::factory (Array (
' items_per_page ' =>20,
' total_items ' = $count,
' uri '= = $this->request->uri (),//optimize paging function, new
));
$current _page = isset ($_get[' page ')? $_get[' page ']:1;
$sql _p. = "LIMIT". (($current _page-1) *20). ", 20";
$p _values = Db::query (Database::select, $sql _p)
->execute ()
->as_array ();
Load attempts to
$view = view::factory (' Fenye ')
->bind ("pagination", $pagination)
->bind ("P_values", $values);
$this->response->body ($view);
}
View file, increase the display of pagination, as follows
<table>
<thead>
<tr>
<th>model</th>
<th> Properties </th>
</tr>
</thead>
<tbody>
<?php foreach ($values as $key = $value) {?>
<tr>
<td></td>
<td></td>
<?php}?>
</tbody>
</table>
<?php echo $pagination;? >//pagination Display
Gleez sub-page function optimization