Hide view with only one result?

I use Drupal 6 and Views to create a series of image galleries. One view creates a full-size slide show, and another view creates a list of thumbnails below the main image. This works great, but when the gallery has only one image, the thumbnail is unnecessary and looks weird.

Is there a way to hide a view containing only one result?

+3
source share
3 answers

No viewing settings. I know that you need to fulfill what you are looking for. However, two ways to do this come to mind ... jQuery or small custom PHP.

JQuery

views-row-N. , jQuery script, , div ( ) views-row-2 . , . , jQuery, div ( , , div), view-view-name. , " ", view-thumbs. , , , , .


PHP

PHP , , , . , , views-view.tpl.php. , Theme: Information, Basic Settings . , , (, Drupal ). views-view.tpl.php ( , ), . . , , , . - $rows. , , . , . , . , , if/else... 2 , , , .


... FireFox FireBug, Devel module , TREMENDOUS .

+2

view-view.tpl.php - .

:

<div class="<?php print $classes; ?> result-count-<?php print count($view->result) ?>">

, .

0

CSS

Unformatted HTML list CSS. , :

.view-id-foobar .views-row-first.views-row-last {
  display: none;
}
-1

Source: https://habr.com/ru/post/1790634/


All Articles