5

I have created a view in order to create a block for slide show in drupal 7. In my view I used a conditional field. This field gets the id of node from URL so I set "When the filter value is NOT available" to "Provide default value" and in TYPE drop down menu I set "Content ID From URL"

Screenshot of view configuration page

This view works with no problem. However, when the view is empty (there is no rows for fetched parameter value from URL) I see some rendered codes.

<div id="block-views-coupon-slides-block" class="block block-views clearfix">
  <div class="content">
    <div class="view view-coupon-slides view-id-coupon_slides view-display-id-block view-dom-id-90e27feb6919634c2f506f189c503c01">
      <div class="view-content">
        <div class="skin-default">
          <div class="views-slideshow-controls-top clearfix">
            <div id="widget_pager_top_coupon_slides-block" class="views-slideshow-pager-fields widget_pager widget_pager_top views_slideshow_pager_field views-slideshow-pager-field-processed">
            </div>
          </div>
          <div id="views_slideshow_cycle_main_coupon_slides-block" class="views_slideshow_cycle_main views_slideshow_main viewsSlideshowCycle-processed">
            <div id="views_slideshow_cycle_teaser_section_coupon_slides-block" class="views-slideshow-cycle-main-frame views_slideshow_cycle_teaser_section">
              <div id="views_slideshow_cycle_div_coupon_slides-block_0" class="views-slideshow-cycle-main-frame-row views_slideshow_cycle_slide views_slideshow_slide views-row-1 views-row-odd">
                <div class="views-slideshow-cycle-main-frame-row-item views-row views-row-0 views-row-first views-row-odd">
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

What is your solution for this problem? As far as I know when a view returns no row, it must not be rendered in source code. In above codes, you see there is no result but the codes of block are printed !!!

Thanks a lot for your guidance.

1 Answer 1

10

You should add a filter criteria for any one of the fields. For example if you have a field called company then you could add a filter criteria for this field and then choose "Is Not Empty (NOT NULL)" from the Drop down. This would make sure that the view is rendered only if the required field is present.

In normal case when you are passing a Contextual filter the view is rendered even though the result is null. but if we provide a filter as I mentioned above it does not display at all.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.