Closed (works as designed)
Project:
Views (for Drupal 7)
Version:
6.x-2.12
Component:
Miscellaneous
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Jan 2011 at 11:10 UTC
Updated:
15 Nov 2012 at 14:28 UTC
I've got a block created from a view that shows the block title even when no data is being returned. I've tried using the view's header but even that shows when it is empty.
I'm running 6.20 and views 6.x-2.12.
This is my exported view:
$view = new view;
$view->name = 'event_details_artists';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
'field_artist_nid' => array(
'label' => '',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 1,
'empty_zero' => 0,
'link_to_node' => 0,
'label_type' => 'custom',
'format' => 'default',
'multiple' => array(
'group' => 0,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => 0,
),
'exclude' => 0,
'id' => 'field_artist_nid',
'table' => 'node_data_field_artist',
'field' => 'field_artist_nid',
'relationship' => 'none',
),
));
$handler->override_option('sorts', array(
'title' => array(
'order' => 'ASC',
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
));
$handler->override_option('arguments', array(
'nid' => array(
'default_action' => 'default',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'breadcrumb' => '',
'default_argument_type' => 'node',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'break_phrase' => 0,
'not' => 0,
'id' => 'nid',
'table' => 'node',
'field' => 'nid',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
'3' => 0,
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_fixed' => '',
'default_argument_user' => 0,
'default_argument_php' => '',
'validate_argument_node_type' => array(
'blog' => 0,
'artist' => 0,
'blogroll' => 0,
'boxes' => 0,
'boxes_images' => 0,
'carousel' => 0,
'event' => 0,
'learning_boxes' => 0,
'page' => 0,
'podcasts' => 0,
'shop' => 0,
'venue' => 0,
'youtube' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'2' => 0,
'1' => 0,
'3' => 0,
),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_php' => '',
),
));
$handler->override_option('filters', array(
'status' => array(
'operator' => '=',
'value' => '1',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status',
'table' => 'node',
'field' => 'status',
'relationship' => 'none',
),
'type' => array(
'operator' => 'in',
'value' => array(
'event' => 'event',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('header_format', '2');
$handler->override_option('header_empty', 0);
$handler->override_option('empty_format', '2');
$handler->override_option('items_per_page', 0);
$handler->override_option('row_options', array(
'inline' => array(),
'separator' => '',
'hide_empty' => 1,
));
$handler = $view->new_display('block', 'Block', 'block_1');
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);
Is this meant to happen? Basically if the view is empty I don't want anything to show.
Comments
Comment #1
merlinofchaos commentedAre you certain the view is actually empty?
From views' perspective, empty means "No records returned". Many people think of empty as "No visible data". But records can be returned with no data; particularly in your case, where you're using a CCK field. It's entirely possible that you could get a node returned that has no field_artist_nid -- you can confirm whether or not this is the case by adding the Node: Nid field. Every node has a nid, so if you're actually getting an invisible record will become visible.
Comment #2
littlemisssunshine commentedAhh so the argument might be causing a result even though there's no node data being returned?
Is there anything I can do if this is the case? Sorry I can't test I'm away from my computer until tomorrow evening.
Comment #3
merlinofchaos commentedGenerally the answer is to add additional filtering to make sure that the records with no visible values are excluded.
Comment #4
littlemisssunshine commentedThank you very much, I've added a not empty filter on the artist node reference field and it works.
Comment #5
drupalreggie commentedgood tip! thank you
Comment #6
abdelatifs commentedHi Guys,
Can Someone Explain How to do that?
That'd save my day.
Thanks
Comment #7
heyehren commentedThanks for this tip!! In my case i found a Global Text Area with no content in it in the Empty Text section... Don't know how it got in there at the first place, but when i removed it the title didn't show anymore for an empty view :)
Comment #8
Sneakyvv commentedThanks a lot!
In my case I had a relation to an entity reference which means I had to add an additional filter that specified the field linking to that entity reference shouldn't be empty.