Closed (fixed)
Project:
Views (for Drupal 7)
Version:
5.x-1.6
Component:
page displays
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
3 Oct 2008 at 18:58 UTC
Updated:
3 Jan 2011 at 16:40 UTC
Hi
I'm having problems trying to show the node header with zero results views. In short, I'd like to get:
View header text
View exposed filters
View empty text
View footer
But instead I get:
View exposed filters
View empty text
View footer
Am I missing something or is there any workaround for this?
Thanks in advance ;)
Comments
Comment #1
jroth commentedI had the same issue. I solved it by removing lines 1531 and 1533 from the theme_views_view function in views.module. Hope this helps.
// if ($num_nodes) {
$output .= views_get_textarea($view, $type, 'header');
// }
Comment #2
merlinofchaos commentedYou hacked a theme function? You ought to be ashamed of yourself for telling people that. Theme functions are overridable. =(
Comment #3
jroth commentedPlease forgive my apparent ignorance here. I am a drupal noob. What do you mean "Theme functions are overridable"? Is there a better way to do this?
Comment #4
merlinofchaos commentedYes, it is possibly Drupal's single most important feature. =)
See: http://drupal.org/node/55126
Though you do have the right direction. If you override that theme function by and make the modification you suggest in your theme, you get the desired result.
Comment #5
jroth commentedmerlinofchaos, thanks for all the help! It is working beautifully and (most important) correctly now. :-)
Comment #6
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #7
ghing commentedHere is my workaround for Views 6.x-2.5, just to help others. I overrode template_preprocess_views_view in my template.php
Comment #8
merlinofchaos commentedIn Views 2 there is a checkbox in with the header that you can use. NO need for that code. :P
Comment #9
hixster commentedIs it possible to show the view header ONLY if the view returns no results. It would be a handy option.
That way the header (or footer) could be used to display useful message like : "your search returned no results, please search again"
Comment #10
NoRandom commentedYes, you can count the results number and using a php header you could do something like:
*code not tested, just written what I remember.
Anyway, why would you want to do that?
I mean you can write this message in the empty text field. Then, check the options "show header/footer even if view has no results" and you'll get the same output without any line of code.
Regards.
UPDATE: Sorry, I didn't notice this issue was for 5.x version wich I think doesn't contain the empty view header option.