/** * Renders the tag * * @param LiquidContext $context */ public function render(&$context) { $this->_collection = $context->get($this->_collectionName); $this->_collectionSize = count($this->_collection); $this->_totalPages = ceil($this->_collectionSize / $this->_numberItems); $paginated_collection = array_slice($this->_collection, $this->_currentOffset, $this->_numberItems); // Sets the collection if it's a key of another collection (ie search.results, collection.products, blog.articles) $segments = explode('.', $this->_collectionName); if (count($segments) == 2) { $context->set($segments[0], array($segments[1] => $paginated_collection)); } else { $context->set($this->_collectionName, $paginated_collection); } $paginate = array('page_size' => $this->_numberItems, 'current_page' => $this->_currentPage, 'current_offset' => $this->_currentOffset, 'pages' => $this->_totalPages, 'items' => $this->_collectionSize, 'previous' => false, 'next' => false); if ($this->_currentPage != 1) { $paginate['previous'] = array('title' => '« Previous', 'url' => $this->current_url() . '?page=' . ($this->_currentPage - 1)); } if ($this->_currentPage != $this->_totalPages) { $paginate['next'] = array('title' => 'Next »', 'url' => $this->current_url() . '?page=' . ($this->_currentPage + 1)); } $context->set('paginate', $paginate); return parent::render($context); }
/** * Renders the block * * @param LiquidContext $context */ public function render(&$context) { $output = parent::render($context); $context->set($this->_to, $output); }
/** * Renders the block * * @param LiquidContext $context */ public function render(&$context) { return parent::render($context); }