예제 #1
0
파일: routes.php 프로젝트: hlogeon/vk-test
/**
 * Find all products that should be rendered on the page provided in arguments
 * Create pagination variables
 * Render view provided in arguments
 * This action currently used in /list route and ajax-list route
 *
 * @param integer $page
 * @param string $view
 * @param array $arguments
 */
function product_list($page, $view, $arguments = [])
{
    if (!is_numeric($page)) {
        renderNotFound();
    }
    $products = pageQuery($page, $arguments);
    $last = end($products);
    $first = $products[0];
    $next = product_make_pager_link($page, $arguments, $last);
    if (intval($page) > 1) {
        $previous = product_make_pager_link($page, $arguments, $first, LINK_PREV);
    } else {
        $previous = false;
    }
    include $view;
}
예제 #2
0
  <ul class="pager">
    <?php 
if ($page == 1) {
    ?>
      <li class="previous disabled"><a href="#">Previous</a></li>
    <?php 
} else {
    ?>
      <li class="previous"><a href="?page=<?php 
    echo $page - 1;
    ?>
">Previous</a></li>
    <?php 
}
?>
    <?php 
if ($last) {
    ?>
      <li class="next disabled"><a href="#">Next</a></li>
    <?php 
} else {
    ?>
      <li class="next"><a href="?<?php 
    echo pageQuery($page + 1);
    ?>
">Next</a></li>
    <?php 
}
?>
  </ul>
</nav>