Hi,
when my view has no results, slideshow still generates html code for a empty slideshow. That is destroying my layout because CSS-styles are still rendered on that empty slideshow markup.

The problem is, that the view doenst return a empty result, it returns an result with one row and only nid set:

#
result (Array, 1 element)

    *
      0 (Object) stdClass
          o
            nid (String, 1 characters ) 5
          o
            node_node_data_field_referenzen_type (NULL)
          o
            node_node_data_field_referenzen_nid (NULL)
          o
            node_node_data_field_referenzen_vid (NULL)

(Copy&Paste form Krumo ;) )

my dirty bugfix: (add it to template.php)

function template_preprocess_views_slideshow_singleframe(&$vars) {
  //Dont show Slideshow when view returns empty result
  $empty = true;
  foreach($vars['view']->result[0] as $attr => $value){
    if($attr != 'nid' && $value != NULL){
      $empty = false;
    }
  }
  if($empty){
    $vars['slideshow'] = '';
  }
}

Can you pls fix that? :)

thx

CommentFileSizeAuthor
#3 1041992-d7-1.patch1.73 KBredndahead
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mallezie’s picture

I confirm this for 6.3 beta 1

I commented the first part of the condition, otherwise it would disable a view of content types without body.

function tmeplate_preprocess_views_slideshow_singleframe(&$vars) {
  //Dont show Slideshow when view returns empty result
  $empty = true;
  /*dsm($vars);*/
  foreach($vars['view']->result[0] as $attr => $value){
    if(/*$attr != 'nid' && */ $value != NULL){
      $empty = false;
    }
  }
  if($empty){
    $vars['slideshow'] = '';
  }
}
snufkin’s picture

But that is not an empty slideshow then, if you have an element in it. You probably mean that you have a slideshow where there are no fields to be displayed are not set?

Also I don't think that any issue with 2.x will be fixed now, you should try it with 3.x, that is the actively developed branch.

redndahead’s picture

Status: Active » Fixed
FileSize
1.73 KB

This is fixed in 6.x-2.x, 6.x-3.x and 7.x-3.x

Status: Fixed » Closed (fixed)

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

FAAREIA’s picture

Version: 6.x-2.3 » 7.x-3.x-dev
Status: Closed (fixed) » Active

I just downloaded the lastest dev and this is not fixed.

Slideshow

$slideshow variable just render the content, so if we have pager, or controler, slideshow is still shown.
To prevent render of $slideshow i just add a if ( !empty($rows[0]) ) { print $slideshow; }" to my views-slideshow.tpl.php

Pager

Pager is still shown even if $slideshow is not printed. We have 3 .tpl

To prevent the render of the pager i add to my custom views-slideshow-pager-fields.tpl.php

<?php
	$li = "/<li ?.*>(.*)<\/li>/";
	preg_match($li, $rendered_field_items, $hay_algo);
	if( !empty($hay_algo[1]) ) {
		print '<ul id="' . $widget_id . '" class="' . $classes . ' paginado">' . $rendered_field_items . '</ul>';
	}
?>

My pager structure -> ul>li>text

My pager views-slideshow-pager-field-item.tpl.php have:
<li id="views_slideshow_pager_field_item_<?php print $variables['location']; ?>_<?php print $variables['vss_id']; ?>_<?php print $variables['count']; ?>" class="slideshow_<?php print $variables['count']; ?>"><?php print $item; ?></li>

My pager "views-slideshow-pager-field-field.tpl.php" has:
<?php print $view->style_plugin->rendered_fields[$count][$field]; ?>

Hope it helps someone
Greetings

Gabriel R.’s picture

Issue summary: View changes

I confirm that this is not fixed in the latest release.

My quick and dirty fix is to copy views-slideshow.tpl.php from the module to my theme and change this:

if (!empty($slideshow)):

…to this:

if (!empty($rows[0])):

  • redndahead committed cb31b24 on 8.x-1.x
    Issue #1041992 by redndahead, axe312: Fixed Empty View Result ->...

  • redndahead committed cb31b24 on 8.x-3.x
    Issue #1041992 by redndahead, axe312: Fixed Empty View Result ->...

  • redndahead committed cb31b24 on 8.x-4.x
    Issue #1041992 by redndahead, axe312: Fixed Empty View Result ->...
NickDickinsonWilde’s picture

Status: Active » Fixed

As far as I can tell this is fixed, if anyone is experiencing this with 7.x-3.2 or higher re-open.

Status: Fixed » Closed (fixed)

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