Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I notice that pager still display if there is only one slide.
I make a dirty fix but that's not a great solution :
// Render all the fields.
$vars['rendered_field_items'] = '';
+ if(count($vars['view']->result)>1) {
foreach ($vars['view']->result as $count => $node) {
$rendered_fields = '';
foreach ($vars['settings']['views_slideshow_pager_fields_fields'] as $field => $use) {
if ($use !== 0 && is_object($vars['view']->field[$field])) {
$rendered_fields .= theme('views_slideshow_pager_field_field', array('view' => $vars['view'], 'field' => $field, 'count' => $count));
}
}
$vars['rendered_field_items'] .= theme('views_slideshow_pager_field_item', array('vss_id' => $vars['vss_id'], 'item' => $rendered_fields, 'count' => $count));
}
+ }
It could be better to add an option in the settings.
Comment | File | Size | Author |
---|---|---|---|
#15 | 1081436-d6-1.patch | 3.81 KB | redndahead |
#15 | 1081436-d7-1.patch | 3.79 KB | redndahead |
#11 | views_slideshow-pager-1081436-11.patch | 3.78 KB | bensey |
#6 | views_slideshow-pager-1081436-6.patch | 3.77 KB | osopolar |
#5 | views_slideshow-pager-1081436-5.patch | 3.77 KB | osopolar |
Comments
Comment #1
redndahead CreditAttribution: redndahead commentedProbably better if it was an option. I know some people who would prefer to have the pager.
Comment #2
core44 CreditAttribution: core44 commentedI cant seem the find the code or similar in version 6.x - 2.x dev. I assume I cant simply apply this my current version. Can anyone suggest how I could achieve the same result with on 6.x - 2.x dev?
Thanks.
Comment #3
bryancasler CreditAttribution: bryancasler commentedI posted a similar request over here 7.x #1126238: Hide pager if only one slide
Marking that one as a duplicate.
Above patch worked great, this is the file you need to change
"\sites\all\modules\views_slideshow\theme\views_slideshow.theme.inc"
Comment #4
redndahead CreditAttribution: redndahead commentedComment #5
osopolarI created this as an option for "Pager fields", called "Hide pager if there is only one slide" with the description "Should the pager be hidden if there is only one slide.". Please review the patch.
I set the default to hide for one slide, because it does not make sense to show the pager if there is only one slide. This will change the default behavior but I think this may be ok, because its currently a developer version.
Comment #6
osopolarFIXED typo in variable.
Comment #7
bryancasler CreditAttribution: bryancasler commentedwoot
Comment #8
osopolarComment #9
kla2t CreditAttribution: kla2t commentedThe same result can be achieved by theming the slideshow without patching the module. Copy "views-slideshow-slide-counter.tpl.php" from "views_slideshow/theme/" to your theme folder and wrap the div with the following condition:
Of course, don't forget to rescan the template files afterwards...
Comment #10
osopolarOf course you can do this just by theming and at the moment it's a nice workaround. Anyway would like to have this done in the module. Would be great if this gets some more reviews.
Comment #11
bensey CreditAttribution: bensey commentedGreat work osopolar, this is an important feature in my opinion.
This patch works well, but there is one problem.
It decides whether to display the pager based on the
$vars['view']->total_rows
variable.After tearing out my hair for a couple of hours as this patch was not working for me, I discovered that this variable is NULL when there is no pager.
See this comment from merlinofchaos: http://drupal.org/node/347819#comment-1189915
A better solution might be to count
the $vars['view']->result
.Here's an updated patch with this change, plus a spelling mistake correction in a comment (pedantic I know! lol.)
Works well for me. Would be great to get this committed.
Comment #12
mattcasey CreditAttribution: mattcasey commentedThe condition in #9 also works with the templates in 6.x-2.3. This makes it a lot cleaner, thanks!
Comment #13
redndahead CreditAttribution: redndahead commentedComment #14
mstrelan CreditAttribution: mstrelan commentedPatch applies cleanly, works as suggested. Thanks so much.
Comment #15
redndahead CreditAttribution: redndahead commentedBasically committed the patch with a few changes.
1) Document change
2) When checking if the pagers should be displayed it should be an && not an ||
3) Default should be off not on since that's the way it is now.
Patches attached. Thank you very much.
Comment #16
castelar CreditAttribution: castelar commentedIs there a way this could work with multi-value image fields? I'd like to hide the pager if there is only one value, and show it if there are more than one.
Comment #17
castelar CreditAttribution: castelar commentedHmm, unchecked it looks like this is working now. Thanks?!
Comment #18
cybermache CreditAttribution: cybermache commentedI'm seeing this in 6.x but it might be the same in 7.x. I have placed css styles associated with my slideshow-controls-bottom div. I was wondering if instead of the children contents disappearing, the whole div would disappear instead, on one slide. So
<div class="views-slideshow-controls-bottom clear-block">
wouldn't be displayed if there is only one slide in the slideshow.Comment #19
redndahead CreditAttribution: redndahead commentedThat's harder because the pager doesn't control that div. That div would also include controls and counters or anything else someone comes up with.
Comment #20
klonosWhen the option is checked the pager doesn't show at all even when there are more than one slides. Using latest 7.x devs of core, views and all related modules.
Comment #21
klonos...never mind. There is a bug already filed for this: #1333026: "Hide pager when there is only one slide" option hides the pager even if there are more than one slides.
Comment #23
cybermache CreditAttribution: cybermache commented@redndahead
I was just thinking of something simple as placing the DIV call within an if|or argument. like if (pager || controls || numbers) {return "
" }.
It's probably much more complex then that and in my defense I haven't begun to sort through the code to even assess whether this argument would work.
I'm just a minimalist when it comes to page layout coding and get squirmy when there are DIV tags that have nothing in them. Alas.