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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

redndahead’s picture

Probably better if it was an option. I know some people who would prefer to have the pager.

core44’s picture

I 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.

bryancasler’s picture

I 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"

redndahead’s picture

Category: bug » feature
osopolar’s picture

I 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.

osopolar’s picture

FIXED typo in variable.

bryancasler’s picture

woot

osopolar’s picture

Status: Active » Needs review
kla2t’s picture

The 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:

<?php if (count($rows) > 1): ?>
<div id="views_slideshow_slide_counter_<?php print $variables['vss_id']; ?>" class="<?php print $classes; ?>">
  <span class="num">1</span> <?php print t('of'); ?> <span class="total"><?php print count($rows); ?></span>
</div>
<?php endif; ?>

Of course, don't forget to rescan the template files afterwards...

osopolar’s picture

Of 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.

bensey’s picture

Great 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.

mattcasey’s picture

The condition in #9 also works with the templates in 6.x-2.3. This makes it a lot cleaner, thanks!

redndahead’s picture

Priority: Normal » Critical
mstrelan’s picture

Status: Needs review » Reviewed & tested by the community

Patch applies cleanly, works as suggested. Thanks so much.

redndahead’s picture

Status: Reviewed & tested by the community » Fixed
FileSize
3.79 KB
3.81 KB

Basically 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.

castelar’s picture

Is 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.

castelar’s picture

Hmm, unchecked it looks like this is working now. Thanks?!

cybermache’s picture

I'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.

redndahead’s picture

That'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.

klonos’s picture

Status: Fixed » Active

When 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.

klonos’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

cybermache’s picture

@redndahead
I was just thinking of something simple as placing the DIV call within an if|or argument. like if (pager || controls || numbers) {return "

$slideshow_control_values

" }.

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.