G'Day,
It looks like the issue of how to hide a Views-panel-pane from a Panel content layout when it is empty is still an issue.
I run into it all the time.
Even though the view itself is set to "hide if no results", Panels will render the over-ridden title, the custom styling for the pane, etc.
This is really problematic, and strangely, I don't see an issue with this title under 7.x
There is an old 6.x thread (http://drupal.org/node/216076) and there is this excellent post by ComputerMinds: (http://www.computerminds.co.uk/articles/hiding-empty-panels-panes)
This issue is a request for:
1. Support on whether there acutally is a clever/elegant way to hide panes completely if there is no content;
2. If not, what is the current best practice to achieve this?
Thanks in advance!
JB
Comments
Comment #1
melsi commentedsorry, wrong button :(
Comment #2
antonyanimator commentedI have the same problem. I can see that there are some ways of doing this with php. But I'm trying to omit as much custom php as possible from my current project. Any updates on this issue anyone?
Comment #3
boabjohn commentedBump please?
Not sure why others are not having this trouble, or why I have not found the answer they have, BUT I'm in the last stages of a production build and have stumbled over this yet again.
In this case we are working with a User view, with a contextual filter looking for a node reference to another user. Ie, If user A has "related to B" set in the node reference field, then we want the view to display that information. If A has no refernece set, then we want the view to simply be HIDDEN.
Because this View is placed only on the User profile page, we will never have a "no argument" situation. So the Contextual filter is set to take its User ID argument from the URL.
In the View display, there are no values for No results, no Headers, and no Footers. In the Views preview mode we see nothing at all rendered when the argument pulls up a user who does not have a node reference set. So all is good at this point.
We place the panel pane display in our User profile page (provide by Panels), and bingo...the view shows up ALL THE TIME...
1. I've made sure there are no straggling characters floating around in the text areas
2. I've tried setting various visibility rules based on default context exists, on customised contexts, and even tried a rules-based visibility.
3. The node pane itself has no overrides set...no title over rides, nada.
So are there any clues I can follow to help figure this out?
Sorry for the bump, and thanks in advance for any insights.
Comment #4
merlinofchaos commentedViews automatically hide if they have no actual content; this indicates that, in fact, for some reason they have content. And when you say "The view shows up" I assume that means it's getting some kind of result that maybe you think it shouldn't?
Comment #5
merlinofchaos commentedThis shows up with Views most commonly when it has results but all fields in the record are empty. That still has 'results' but nothing is actually visible, and it usually means that there's something subtly incorrect about the filtering of the view.
Comment #6
boabjohn commentedG'Day Merlin,
Thanks for the the reply and encouragment to keep looking. I think we got this one sorted out.
When you say 'subtle', you're not kidding.
In case it might help others, here's what our experience was in this case.
CAUSES PANE TO REMAIN VISIBLE
1. Relationship was set to "content entity referenced by..."
2. UID was coming straight from URL
3. Fields were set to use the relationship
ALLOWS PANE TO BE HIDDEN
1. Relationship set to "content entity referencing..."
2. UID coming from URL, via relationship
3. Fields set to not use relationship
So basically both configurations produce the expected output at the level of Views, but when Panels sees them, there is a difference that makes a difference.
Kind regards.
Comment #7
Marko B commentedI have similar problem, no relationships and referencing but the problem is the same.
http://drupal.org/node/1912218#comment-7044168
@Merlin If you are saying there in fact some results but they are empty, how could this be possible to check (some output)?
In my case it seems then the result I am getting is node, and THAT IS A RESUSLT. Problem is that node's gallery field is empty, and I would expect nothing to show but title and navigation of jCarousel still shows up. It shows up as the result is node, not the CCK field. So then what I thought of is this. Instead of using some custom stuff. I just did this. I added a views filter.
Content: Images:delta (not empty) which basicly cheks if there is some images in this gallery, if not view will not display any results, and this WORKS. I belive many will have similar questions with this as this is not the first thing you would think.
Comment #8
Marko B commentedTried to explain it better here
http://drupaldump.com/hide-empty-panel-drupal-views-pane-mini-panels
Comment #9
zionduc commentedI think the Views filter solution in the #7 comment is very simple and do the job.
Thank you!
Comment #10
boabjohn commentedSorry, this is closed (for the benefit of the Views team: nothing new to deal with) but for the sake of anyone else struggling through here...another observation similr to #6 above.
With a node and a taxonomy term. The term is referenced from the node. So we have a taxonomy reference field.
Now suppose you are on the taxonomy term page, and want to display the titles of nodes which have referenced this term. This will be achieved by creating a views panel pane display. There should be a title to the pane: this can be entered in the views display title, or the panel pane title or both with an override.
We do not want this title to display in a 'no results' situation. The view is (ostensibly) returning no values (view is hidden) and the pane should not display if there is no views content. Fine...taht's the situation.
Now, what about this view.
You can create a view that filters on terms, and use a relationship to grab titles from the target nodes by using relationships...all perfectly legal syntax. In a 'no results' situation either the view's display title or the panel pane's title will display no matter what you do. This is the hair-pulling option.
You can also create a view that filters on nodes, and use relationshipos to grab the TID via the related field on the nodes...all perfectly legal syntax. This will behave just the way we wanted it to. This is the smiling option.
Hope that's a bit helpful. Cheers!
Comment #11
merlinofchaos commentedYou never need to apologize for providing more and useful information!
Comment #12
boabjohn commented(maintainer alert: no issue here...just added documentation on the issue)
Looks like I have this thread all to myself now, but I'll add another 'trick' discovered today.
For the past 7 years I've managed to do some pretty tricky things with Views and yet never explored the hidden meanings of the tickbox [ ] Require this relationship under the Relationship options.
In today's learning moment I had once again found that my "empty" views were still being read by Panels as containing some markup, which triggered Panels to display the pane title. Even following my own advice above (#6, #10) did not help.
Since the problem seems to come from the presence of a relationship (somehow it causes in an empty div /div to be rendered), I was just starting to hoe into the relationship configs.
I looked more closely at the literal meaning of the Require Relationship tickbox (clearly labeled), and decided to give it a try. Worked like a charm.
Relationships where a referenced node exists get written; relationships where no referenced node is found simply get "filtered" from any further Views markup...and that stops it from writing anything out where Panels can find it (and get confused).
Note to self: given the number of posts on this topic, perhaps it would benefit from a documentation page?
Comment #13
shaundychko#12 for the win! Thank you very much.