Posted by Romel Verterra on April 9, 2009 at 4:18am
| Project: | Custom Pagers |
| Version: | 6.x-1.x-dev |
| Component: | User interface |
| Category: | feature request |
| Priority: | major |
| Assigned: | Unassigned |
| Status: | active |
| Issue tags: | custom pagers, module, node titles, pagination |
Issue Summary
Hi, great module and I like it very much. I think it is better if we have an option to display "" into "". The display "" is great for image galleries and the display "" is great for blog and other articles. Just my opinion. Thank you for this module. :)
Comments
#1
Hi I want to retype my request because my < and > turned into html tags. I cannot edit my request, lesson for not previewing it.
What I mean in my request is to have an option to display "<title-of-previous-node # of # title-of-next-node>" and "<previous # of # next>".
"<title-of-previous-node # of # title-of-next-node>" is good for blog.
"<previous # of # next>" is good for images. Thanks again.
#2
My vote for this
#3
Can someone please adapt the 5x solution to this? I really need the titles to be shown, there's no reason, and me personally, that one would click on a random "next previous" button without knowing what they're clicking on. I understand the switch was made for speed but the point is usability otherwise the module is useless.
#4
I agree with fluidicmethod, when can we expect to see this implemented, wasted my time installing it, can you at least mention it on the screenshot link from your project page!! very misleading!!
#5
I really want this feather. Anyone?
#6
Subscribing.. I see the need for this as well.
#7
Subscribing .... It's a must have feature, I think.
#8
To output titles instead of prev/next, just modify 5 lines of code in the file custom_pagers/custom_pagers.module.
<?php
function custom_pagers_preprocess_custom_pager(&$vars) {
drupal_add_css(drupal_get_path('module', 'custom_pagers') .'/custom_pagers.css');
$node = $vars['node'];
$pager = $vars['pager'];
$nav = $vars['nav_array'];
// new lines for the titles
$nextTitle = isset($nav['next']) ? check_plain(db_result(db_query('SELECT title FROM {node} WHERE nid = %d',$nav['next']))) : '';
$prevTitle = isset($nav['prev']) ? check_plain(db_result(db_query('SELECT title FROM {node} WHERE nid = %d',$nav['prev']))) : '';
$vars['previous'] = !empty($nav['prev']) ? l($prevTitle, 'node/'. $nav['prev']) : '';
$vars['key'] = t('@count of @count_total', array('@count' => ($nav['current_index'] + 1), '@count_total' => count($nav['full_list'])));
$vars['next'] = !empty($nav['next']) ? l($nextTitle, 'node/'. $nav['next']) : '';
// comment out these 3 lines
// $vars['previous'] = !empty($nav['prev']) ? l('‹ ' . t('previous'), 'node/'. $nav['prev']) : '';
// $vars['key'] = t('@count of @count_total', array('@count' => ($nav['current_index'] + 1), '@count_total' => count($nav['full_list'])));
// $vars['next'] = !empty($nav['next']) ? l(t('next') . ' ›', 'node/'. $nav['next']) : '';
$vars['suggestions'][] = "custom-pager-{$vars['position']}";
$vars['suggestions'][] = "custom-pager-$node->type";
$vars['suggestions'][] = "custom-pager-$node->type-{$vars['position']}";
$vars['suggestions'][] = "custom-pager-$pager->pid";
$vars['suggestions'][] = "custom-pager-$pager->pid-{$vars['position']}";
}
?>
Maybe there is a better solution, but this works fine for me.
The following link contains the modification which is described above, you can see it in action: Junggesellenabschied T-Shirt bedrucken
Hope a feature like this will be in a future release :)
Have fun!
#9
This was addressed in version 6.x-1.x-dev - see http://drupal.org/node/516862 for a self-made patch or use the attached file (had to zip the one file in order to attach it). Works like a charm on my website blog - http://peterpetrik.com/blog
Peter...
#10
Nice module, but screenshot was a bit misleading.
Letrice/slovak, could you suggest a solution for the 5.x-1.9 version?
#11
add this in your template.php.tpl
<?php
function phptemplate_preprocess_custom_pager(&$vars) {
$nav = $vars['nav_array'];
$prev = 'prev';
if (!empty($nav['prev'])) {
$nodeObj = node_load($nav['prev']);
if ($nodeObj) {
$prev = node_page_title($nodeObj);
}
}
$next = 'next';
if (!empty($nav['next'])) {
$nodeObj = node_load($nav['next']);
if ($nodeObj) {
$next = node_page_title($nodeObj);
}
}
$vars['previous'] = !empty($nav['prev']) ? l('‹ ' . $prev, 'node/'. $nav['prev']) : '';
$vars['next'] = !empty($nav['next']) ? l($next . ' ›', 'node/'. $nav['next']) : '';
}
?>
#12
Has anybody tried the patch from #9 with the latest beta-2?
#13
NUmber 11 works, great!
#14
none worked for me...
#15
I can confirm #11 worked for me.
#16
did you past this or replace code in theme folder of drupal site or module?
#17
Put the following in your template.php (make sure to change where it says "theme-name" to your theme's exact name and to not include the
<?php ?>tags):<?php
function THEME-NAME_preprocess_custom_pager(&$vars) {
$nav = $vars['nav_array'];
$prev = 'prev';
if (!empty($nav['prev'])) {
$nodeObj = node_load($nav['prev']);
if ($nodeObj) {
$prev = node_page_title($nodeObj);
}
}
$next = 'next';
if (!empty($nav['next'])) {
$nodeObj = node_load($nav['next']);
if ($nodeObj) {
$next = node_page_title($nodeObj);
}
}
$vars['previous'] = !empty($nav['prev']) ? l('‹ ' . $prev, 'node/'. $nav['prev']) : '';
$vars['next'] = !empty($nav['next']) ? l($next . ' ›', 'node/'. $nav['next']) : '';
}
?>
#18
No still didnt work for me even if I added my theme name which is something like this - theme_name :/
#19
I the name of your the was 'Garbund', you would write
function garbund_preprocess_custom_pager..., notfunction theme_garbund_preprocess_custom_pager...#20
no my theme is simply_modern that is what I replaced with THEME-NAME
#21
#17 works great, but it is possible to only show the first xx letters of the title? I did it in the views definition, but it didn't work with the code... Any ideas?
Edit: Ok I did it like this:
$prev = mb_strcut($prev, 0, 40);$prev = $prev."...";
and likewise with next.
Hope this is ok, at least it works :)
#22
#11 works for me, but you will have to replace the "‹" with a real "<" and similarly for the close-angle bracket.
#23
@11 your code not worked for me
where i put that code?
#24
I created this, it's not perfect, but it does give you the option to change this per pager.
This will also patch the tpl.php file, cause this order makes more sense when you enable this feature.
It will present an option at the 'add custom pager' page where you can 'enable' the feature.
Hope it helps. :) (be sure to reinstall the module, else it wont work. i didn't create an update)
#25
Reworked the patch, use this patch, forget the first one.
Changed a lot, so it contains:
- patch against 1.0 beta2
- adds an option to enable the nodetitle on pager functionality on the admin page
- added an option to limit the length of a title on the admin page
- it will change your custom-pager-tpl.php file.
Still wonder if it's smart to use node_load to fetch the title, any suggestions?
#26
And to finish it up for today, the mysql query from #8 added. This should do it.
#27
this patch didn't worked for me. it gives parse error. actually I am new to doing patch. is there anyone who successfuly use this patch ?
#28
(ill rework the patch, made a mistake creating it, you have to run it from the modules dir, not inside the custompagers dir. and i changed some other issues, ill post it later next week, got a busy schedule.)
#29
Patch #26 works for me
#30
Thank you letrice
#31
#8 worked except on node titles that contain quotes in them. I removed check_plain on the first part because l() runs check plain also and it was running the title through twice.
#32
I am using two different pagers and would like to use node titles in custom pager id2, but not in custom pager #1. Is this possible?
I couldn't find a way to create two different functions like
function THEME-NAME_preprocess_custom_pager_1andfunction THEME-NAME_preprocess_custom_pager_2in template.php.Maybe it is possible to move the logic from template.php into a template file like
custom-pager-2.tpl.php?Thanks!