Greets, first of all thanks, views is probably the main reason I am using drupal.
I am wanting to use different theme for the pager that gets outputted in a node tpl on a view like this
$view = views_get_view('new_art_gallery_view') or die ('no such view');
$view->set_display('Page');
$view->display_handler->set_option('items_per_page', 2);
$view->display_handler->set_option('use_pager', 'custom');
print $view->preview(NULL, array('a', 'possible', 'array', 'of', 'arguments'));
After checking out that in views theme.inc the function theme_views_mini_pager around line 600 is mostly a modified version of http://api.drupal.org/api/function/theme_pager/6 please excuse my very very quick and dirty hack on function template_preprocess_views_view around line 80 and made my own function theme_views_custom_pager.
if ($view->pager['use_pager'] == 'custom'){
$pager_type = ($view->pager['use_pager'] === 'custom' ? 'views_custom_pager' : 'pager');
$pager_theme = views_theme_functions($pager_type, $view, $view->display_handler->display);
$vars['pager'] = theme($pager_theme, $exposed_input, $view->pager['items_per_page'], $view->pager['element']);
} elseif ($view->pager['use_pager'] == 'mini') {
$pager_type = ($view->pager['use_pager'] === 'mini' ? 'views_mini_pager' : 'pager');
$pager_theme = views_theme_functions($pager_type, $view, $view->display_handler->display);
$vars['pager'] = theme($pager_theme, $exposed_input, $view->pager['items_per_page'], $view->pager['element']);
}
I would really like being able to theme pagers in a more themer friendly way specific to each view, I am no programmer so I would have no idea how to do more. What a themer needs is a short example of how to create custom pager type(s) in a drupal friendly way. Also having that pager type show up in the views ui would be a big help.
Thank you for your time, I am interested in any thoughts on this issue, after searching there doesn't seem to be much more info around.
Comments
Comment #1
imp7 commentedIt does work you just also have to add in the views.module file an entry for every pager function you want, copy from line 32 $hooks['views_mini_pager']
Comment #2
dawehnerYou can do this also in your own hook_theme
Comment #3
imp7 commentedComment #4
imp7 commentedThanks for the advice dereine, could you be a little more specific, or do you know of a link to read from that describes what you mean by that? I wouldnt know where to start :)
Comment #5
Gabriel R. commentedI changed the title of the page to make it clearer and easier to google.
Comment #6
YK85 commentedI'm having a hard to understanding how to theme the pager.
I would like to achieve something like the pager shown at http://drupal.org/project/issues/user
Is there a tutorial or can someone help? Thanks!
Comment #7
imp7 commentedyaz085 is there something in particular you don't understand about the posts above? You may have to start reading the begging of the drupal handbook as I would not know where to begin to explain such a thing http://drupal.org/theme-guide/6.
I am still interested in how other developers have approached themeing the pagers individually, I haven't really changed the way I do it since I made the post.
Comment #8
kelvincool commentedThemeing a pager for a specific view is possible. For example, if you had a mini pager on a view block called ticker, the themeing functions available are:
views_mini_pager__ticker__block_1, views_mini_pager__block_1, views_mini_pager__, views_mini_pager__ticker__block, views_mini_pager__block, views_mini_pager__ticker, views_mini_pagerThen all you need to do is copy the theme_views_mini_pager function into your template.php and change it however you want. For example to only theme the pager on block 1 in my ticker view I would use theme_views_mini_pager__ticker__block_1
If you need to find out all the templates available, put this code on line 85 in theme.inc within the views/theme/ folder
var_dump($pager_theme);exit;This will give you an output of all the themeing functions the view pager can use.
Comment #9
imp7 commentedthanks kelvincool, that is pretty handy to know.
Comment #10
esmerel commentedComment #12
OxH2 commentedthanks for the clear info - this really helped me out
my new function did not work at first and produced next and previous links without closing tags
narrowed this issue down to the document encoding of template.php as described in this post:
http://drupal.org/node/503062
Comment #13
open social commentednice, this is what I was searching for!
Comment #14
devkinetic commentedAs an update in the latest views (d6) the line for the var_dump (as detailed in #8) is 97.
Comment #15
delioni have dumped the view block id's and tried multiple ones and still none of them seem to override the mini pages of this block that i have. here is the function i am using.
Comment #16
phponwebsites commentedI have created a page with 2 pager. I have displayed both pager items in tab1 and tab2. The tab2 have been displayed by default. If I click pager of tab1, then it have displayed by default tab2.
So i want to change active class based on tab's pager. For that i want to pass custom argument with page number into url. If i will do this, then i can displayed correct tab.
ie, my url should be ?page=1&type=tab1, if i click pager of tab1.
i have tried hook_views_pre_build(), but i didn't know how to pass arguments into views pager.
If i had used theme(pager), then i can pass values as argument.
Below is the sample code:
$args = array('parameters' => array('type' => 'recent'));
theme('pager', $args);
Due to above code, my url looks like 'http://www.example.com/sample?type=recent&page=1'
I want to do same for views pager.