当前位置: 首页>>代码示例>>PHP>>正文


PHP Paginator::render方法代码示例

本文整理汇总了PHP中Paginator::render方法的典型用法代码示例。如果您正苦于以下问题:PHP Paginator::render方法的具体用法?PHP Paginator::render怎么用?PHP Paginator::render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Paginator的用法示例。


在下文中一共展示了Paginator::render方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCatalogueItem

 /** get Catalogue Item
  * @param $path
  * @return array
  */
 private function getCatalogueItem($path)
 {
     $data = array();
     $path_items = CatalogueUtils::getPathItems($path);
     $catalogue = array();
     $catalogue["path_items"] = $path_items;
     $last = count($path) - 1;
     $catalogue["current_label"] = $path[$last];
     /*
      * // prev item categories list
      *
     $arr = $this->address["path"];
     array_pop($arr);
     $catalogue["prev_item_path"] = implode("/", $arr);
     
     $pre_last = count($this->address["path"]) - 2;
     if ($pre_last >= 0){
         $childrenId = $path_items[$pre_last]["children_id"];
         $current_categories = CatalogueUtils::getProducts($childrenId);
     }
     */
     if (count($path) > 1) {
         $childrenId = $path_items[0]["children_id"];
         $current_categories = CatalogueUtils::getProducts($childrenId);
         G::addToRender("blocks/sidebar_navigation.php", BLOCK_SIDEBAR_LEFT, CODE);
     } else {
         G::addToRender("<h1>" . G::$language->getText("common", "catalogue_link_text") . "</h1>", BLOCK_CONTENT);
     }
     $childrenId = $path_items[$last]["children_id"];
     $products = array();
     if ($path_items[$last]["type"] != TYPE_CATEGORY) {
         // single product
         $node = CatalogueUtils::getCatalogueNode($path_items[$last]["label"]);
         $current_product = new ProductItem($node);
         # required class ProductItem
         $data = $this->parsePageData($node);
         // "if hidden" HERE because - admin mode should load data of hidden elements
         if (!$path_items[$last]["hidden"]) {
             G::addToRender("catalogue/catalogue_single_product.php", BLOCK_CONTENT, CODE);
             G::addToRender("blocks/brand_block.php", BLOCK_SIDEBAR_RIGHT, CODE);
         } else {
             //$this->redirect(PAGE_PAGE404); when not AJAX
             $message = "<p class='grey-text' align='center'>" . G::$language->getText("catalogue", "category_fail") . "</p>";
             G::addToRender($message, BLOCK_CONTENT);
         }
     } else {
         $node = CatalogueUtils::getCatalogueNode($path_items[$last]["label"]);
         $current_product = new ProductItem($node);
         $data = $this->parsePageData($node);
         if (strlen($childrenId) > 0) {
             //multiple categories|products
             $total = count(explode(",", $childrenId));
             $page = intval($_GET["page"]);
             $items_limit = isset($_SESSION["page_items_limit"]) ? $_SESSION["page_items_limit"] : Paginator::PAGE_ITEMS_LIMIT;
             $max_pages = ceil($total / $items_limit);
             if ($page > $max_pages) {
                 $_GET["page"] = $page = $max_pages;
             }
             if ($total > $_SESSION["page_items_limit"]) {
                 $paginator = new Paginator($max_pages, $page);
                 G::addToRender($paginator->render(), BLOCK_CONTENT, TEXT);
             }
             $products = CatalogueUtils::getProducts($childrenId, $_SESSION["page_items_limit"], $page);
         }
         if ($products && count($products) > 0) {
             G::addToRender("catalogue/catalogue_page_blocks.php", BLOCK_CONTENT, CODE);
             //                die("HERE:".count($products));
         } else {
             // no products in category
             $message = "<p class='grey-text' align='center'>" . G::$language->getText("common", "empty_category") . "</p>";
             G::addToRender($message, BLOCK_CONTENT);
         }
     }
     $data["current_categories"] = $current_categories;
     $data["catalogue"] = $catalogue;
     $data["products"] = $products;
     $data["current_product"] = $current_product;
     // DEBUG
     $data["access"] = 4;
     if (!isset($data["title"])) {
         $data["title"] = G::$language->getText("common", "catalogue_link_text");
     }
     $data["blocks_id"] = "1,3,4,5,6,7,8,9,10,11,12,15";
     //
     return $data;
 }
开发者ID:elijahGraff,项目名称:stoma-dental,代码行数:90,代码来源:PageData.php

示例2: LimitIterator

        }
        if (!empty($limit)) {
            $this->setItemsPerPage($limit);
        }
        // quickly calculate the offset based on the page
        if ($page > 0) {
            $page -= 1;
        }
        $offset = $page * $this->_itemsPerPage;
        // return the limit iterator
        return new LimitIterator($this->_it, $offset, $this->_itemsPerPage);
    }
}
// generate an example of page items to iterate over
$items = array(array('id' => 1, 'name' => 'Item 1', 'desc' => 'Description', 'price' => 4.99), array('id' => 2, 'name' => 'Item 2', 'desc' => 'Description', 'price' => 4.99), array('id' => 3, 'name' => 'Item 3', 'desc' => 'Description', 'price' => 4.99), array('id' => 4, 'name' => 'Item 4', 'desc' => 'Description', 'price' => 4.99), array('id' => 5, 'name' => 'Item 5', 'desc' => 'Description', 'price' => 4.99), array('id' => 6, 'name' => 'Item 6', 'desc' => 'Description', 'price' => 4.99), array('id' => 7, 'name' => 'Item 7', 'desc' => 'Description', 'price' => 4.99), array('id' => 8, 'name' => 'Item 8', 'desc' => 'Description', 'price' => 4.99), array('id' => 9, 'name' => 'Item 9', 'desc' => 'Description', 'price' => 4.99), array('id' => 10, 'name' => 'Item 10', 'desc' => 'Description', 'price' => 4.99), array('id' => 11, 'name' => 'Item 11', 'desc' => 'Description', 'price' => 4.99), array('id' => 12, 'name' => 'Item 12', 'desc' => 'Description', 'price' => 4.99), array('id' => 13, 'name' => 'Item 13', 'desc' => 'Description', 'price' => 4.99), array('id' => 14, 'name' => 'Item 14', 'desc' => 'Description', 'price' => 4.99), array('id' => 15, 'name' => 'Item 15', 'desc' => 'Description', 'price' => 4.99), array('id' => 16, 'name' => 'Item 16', 'desc' => 'Description', 'price' => 4.99), array('id' => 17, 'name' => 'Item 17', 'desc' => 'Description', 'price' => 4.99), array('id' => 18, 'name' => 'Item 18', 'desc' => 'Description', 'price' => 4.99), array('id' => 19, 'name' => 'Item 19', 'desc' => 'Description', 'price' => 4.99), array('id' => 20, 'name' => 'Item 20', 'desc' => 'Description', 'price' => 4.99), array('id' => 21, 'name' => 'Item 21', 'desc' => 'Description', 'price' => 4.99));
// load the paginator
$Paginator = new Paginator(new ArrayIterator($items));
// displays the initial set (page 1, limit 10)
$results = $Paginator->render();
foreach ($results as $r) {
    var_dump($r);
}
// check for another page
if ($Paginator->hasNextPage()) {
    echo 'DISPLAYING THE NEXT SET OF RESULTS AS AN EXAMPLE' . PHP_EOL;
    // displays the next page results as an example
    $results = $Paginator->render($Paginator->getCurrentPage() + 1);
    foreach ($results as $r) {
        var_dump($r);
    }
}
开发者ID:pixlr,项目名称:ZCE-PHP-Cert,代码行数:31,代码来源:limit-iterator.php


注:本文中的Paginator::render方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。