Skip to content

Commit

Permalink
Fixed pagination for user timeline
Browse files Browse the repository at this point in the history
- Use a placeholder to store base URL information
- Pull url information in pagination control partial to build base url
  • Loading branch information
weierophinney committed Aug 29, 2012
1 parent 3b8f4ab commit dbedfef
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
5 changes: 5 additions & 0 deletions view/phly-peep/peep/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
echo $this->render('phly-peep/peep/peep', array('peep' => $peep));
}

$paginationInfo = $this->placeholder('phly-peep-pagination');
if (!isset($paginationInfo->route)) {
$paginationInfoInfo->route = 'phly-peep';
$paginationInfoInfo->params = array();
}
echo $this->paginationControl($this->peeps, 'Sliding', 'phly-peep/peep/pagination');
endif; ?>
</div>
Expand Down
12 changes: 8 additions & 4 deletions view/phly-peep/peep/pagination.phtml
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
<?php if ($this->pageCount): ?>
<?php
$paginationInfo = $this->placeholder('phly-peep-pagination');
$baseUrl = $this->url($paginationInfo->route, $paginationInfo->params);

if ($this->pageCount): ?>
<div class="pagination"><ul>

<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
<li><a href="<?php echo $this->url('phly-peep'); ?>?page=<?php echo $this->previous ?>">Prev</a></li>
<li><a href="<?php echo $baseUrl; ?>?page=<?php echo $this->previous ?>">Prev</a></li>
<?php else: ?>
<li><a href="#">Prev</a></li>
<?php endif; ?>

<!-- Numbered page links -->
<?php foreach ($this->pagesInRange as $page): ?>
<?php if ($page != $this->current): ?>
<li><a href="<?php echo $this->url('phly-peep') ?>?page=<?php echo $page ?>"><?php echo $page; ?></a></li>
<li><a href="<?php echo $baseUrl ?>?page=<?php echo $page ?>"><?php echo $page; ?></a></li>
<?php else: ?>
<li class="active"><a href="#"><?php echo $page; ?></a></li>
<?php endif; ?>
<?php endforeach; ?>

<!-- Next page link -->
<?php if (isset($this->next)): ?>
<li><a href="<?php echo $this->url('phly-peep'); ?>?page=<?php echo $this->next ?>">Next</a></li>
<li><a href="<?php echo $baseUrl; ?>?page=<?php echo $this->next ?>">Next</a></li>
<?php else: ?>
<li><a href="#">Next</a></li>
<?php endif; ?>
Expand Down
7 changes: 6 additions & 1 deletion view/phly-peep/peep/username.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ if (!isset($this->username)) {
</div>
</div>

<?php echo $this->render('phly-peep/peep/index');
<?php
$paginationInfo = $this->placeholder('phly-peep-pagination');
$paginationInfo->route = 'phly-peep/user';
$paginationInfo->params = array('username' => $this->username);

echo $this->render('phly-peep/peep/index');

0 comments on commit dbedfef

Please sign in to comment.