I have a view on my front page showing the latest posts, but the design of the website implicates the pager to be located outside the content area of the view (way across in the sidebar). Is there a way I can place the pager in the sidebar in page.tpl.php? I'm using my own custom theme. Any help is greatly appreciated, otherwise I'll have to hack up some CSS positioning but I'd rather learn more about drupal 7!



The following steps might help you to extract the pager out of a view conatiner with a help of small css fix,

1 : Override the view template file I have created a view called extract pager and created a custom tpl for the same views-view--extract-pagertpl.php

2 : The data-members for pager will be available in the above tpl file copy and place the code into to a sepearte div container

<div class="pager-extract">
  <?php if ($pager): ?>
    <?php print $pager; ?>
  <?php endif; ?>

3 : Rescan the template files in the views and save the view.

4 : The above steps will help you to bring out the pager up to the view content block, use few css styles to theme your pager as per your requirements.

Screen shot


Separating pieces of content in Drupal is easy if the module returns render arrays instead of actual markup: just use hook_page_alter. Unfortunately, that's not the case for Views :/

Another trivial solution would be to print your view twice: once in the main content, again in a block (a separate display). Then, when it comes to theme the block, override the template and remove everything but the pager. Done! (see http://www.adesignforlife.net/articles/drupal-tutorials/solution-how-print-pager-drupal-views-block for more details).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.