Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Work on custom pagination layout.

  • Loading branch information...
commit ffbd2452ccd960d9871de2601a3903d90e432aee 1 parent 5e8218e
@saltybeagle saltybeagle authored
View
BIN  .cache/.dataModel
Binary file not shown
View
36 src/UNL/MediaYak/List/PagerLayout.php
@@ -0,0 +1,36 @@
+<?php
+class UNL_MediaYak_List_PagerLayout extends Doctrine_Pager_Layout
+{
+public function display($options = array(), $return = false)
+ {
+ $pager = $this->getPager();
+
+ $this->setTemplate('<li><a href="{%url}" title="Go to page {%page}">{%page}</a></li>');
+ $this->setSelectedTemplate('<li class="selected">{%page}</li>');
+
+ $str = '<ul class="wdn_pagination">';
+
+ // Previous page
+ $this->addMaskReplacement('page', '&larr; prev', true);
+ $options['page_number'] = $pager->getPreviousPage();
+ $str .= $this->processPage($options);
+
+ // Pages listing
+ $this->removeMaskReplacement('page');
+ $str .= parent::display($options, true);
+
+ // Next page
+ $this->addMaskReplacement('page', 'next &rarr;', true);
+ $options['page_number'] = $pager->getNextPage();
+ $str .= $this->processPage($options);
+
+ $str .= '</ul>';
+
+ // Possible wish to return value instead of print it on screen
+ if ($return) {
+ return $str;
+ }
+
+ echo $str;
+ }
+}
View
10 www/templates/html/FeedList.tpl.php
@@ -3,11 +3,9 @@
<p>Select a channel to view.</p>
<?php
if (count($context->items)) {
- $pager_layout = new Doctrine_Pager_Layout($context->pager,
- new Doctrine_Pager_Range_Sliding(array('chunk'=>5)),
- UNL_MediaYak_Controller::getURL(null, array_merge($context->options, array('page'=>'{%page_number}'))));
- $pager_layout->setTemplate(' <a href="{%url}">{%page}</a> ');
- $pager_layout->setSelectedTemplate('{%page}');
+ $pager_layout = new UNL_MediaYak_List_PagerLayout($context->pager,
+ new Doctrine_Pager_Range_Sliding(array('chunk'=>5)),
+ UNL_MediaYak_Controller::getURL(null, array_merge($context->options, array('page'=>'{%page_number}'))));
$pager_links = $pager_layout->display(null, true);
echo '<ul>';
foreach ($context->items as $feed) {
@@ -18,7 +16,7 @@
echo '</ul>';
?>
<em>Displaying <?php echo $context->first; ?> through <?php echo $context->last; ?> out of <?php echo $context->total; ?></em>
- <div class="wdn_pagination"><?php echo $pager_links; ?></div>
+ <?php echo $pager_links; ?>
<?php
} else {
echo '
View
6 www/templates/html/MediaList.tpl.php
@@ -7,11 +7,9 @@
}
if (count($context->items)) {
- $pager_layout = new Doctrine_Pager_Layout($context->pager,
+ $pager_layout = new UNL_MediaYak_List_PagerLayout($context->pager,
new Doctrine_Pager_Range_Sliding(array('chunk'=>5)),
UNL_MediaYak_Controller::getURL(null, array_merge($context->options, array('page'=>'{%page_number}'))));
- $pager_layout->setTemplate(' <a href="{%url}">{%page}</a> ');
- $pager_layout->setSelectedTemplate('{%page}');
$pager_links = $pager_layout->display(null, true);
?>
<ul class="medialist">
@@ -41,7 +39,7 @@
} ?>
</ul>
<em>Displaying <?php echo $context->first; ?> through <?php echo $context->last; ?> out of <?php echo $context->total; ?></em>
- <div class="wdn_pagination"><?php echo $pager_links; ?></div>
+ <?php echo $pager_links; ?>
<?php
} else {
echo '<p>Sorry, no media could be found</p>';

0 comments on commit ffbd245

Please sign in to comment.
Something went wrong with that request. Please try again.