NodeNav Pagination

This example assumes that the user has instantiated a nav as follows:

<?php
// Get the user input value for the page selection
$this->setInputValue('page');
if(!$this->arr_input['page']){
$this->arr_input['page'] = 1;
}
// Instantiate a node nav for the current node
$nodenav = $this->getNodeNav($this->document->currentnode->id);
// Get a page of links
$nodenavpage = $nodenav->getPage('document' , 'document_title ASC' , 32 , $this->arr_input['page']);
?>

Having created the nav, a typical pagination block would consist of the following:

Page position information

The following code will produce a page position text, eg "Page 1 to 30 of 135"

Page <?php echo htmlspecialchars($nodenavpage->pagination['result_from']) ?> to <?php echo htmlspecialchars($nodenavpage->pagination['result_to']) ?> of <?php echo htmlspecialchars($nodenavpage->pagination['total_results']) ?>

Pagination links

The following code will produce next / previous buttons and 1 , 2 , 3 , 4 etc links.

<?php if($nodenavpage->pagination['previous'] || $nodenavpage->pagination['next']) { ?>
<ul class="pagination pull-right" style="margin: 0;">
<?php  if($nodenavpage->pagination['previous']) { ?>
<li>
<a href="<?php echo $this->getListLink(array('page' => $nodenavpage->pagination['previous']))?>">Previous</a>
</li>
<?php } else { ?>
<li class="disabled">
<a href="" class="pagination-select">Prev</a>
</li>
<?php } ?>
<?php for($i=$nodenavpage->pagination['paging_count_start']; $i<$nodenavpage->pagination['paging_count_end']; $i++) { ?>
<li<?php if($this->arr_input['page'] == $i) { echo ' class="active"'; } ?>>
<a href="<?php echo $this->getListLink(array('page' => $i)) ?>"><?php echo $i ?></a>
</li>
<?php } ?>
<?php if($nodenavpage->pagination['next']) { ?>
<li>
<a href="<?php echo $this->getListLink(array('page' => $nodenavpage->pagination['next']))?>">Next</a>
</li>
<?php } else { ?>
<li class="disabled">
<a href="" class="pagination-select">Next</a>
</li>
<?php } ?>
</ul>
<?php } ?>
 

Contact Us

Address: 22a Fishergate York, YO10 4AB · Tel: 01904 636677 · Email: info@dotadmin.com