Closed (outdated)
Project:
Views Field View
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
14 Mar 2011 at 09:41 UTC
Updated:
26 Apr 2020 at 16:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
pontus_nilssonThis can be solved by adding a template file for the view that is added as a field to your view that strips out the surrounding div for the view.
Comment #2
damien tournoud commentedRetitling, bumping.
This module uses views_embed_view() directly. It should be easy to render the view ourselves and add the option to not return anything if the child view has an empty result set.
Comment #3
damien tournoud commentedThis is technically more a feature request.
Comment #4
the_paulus commentedHere is how I got around the problem. I created a module and added this function:
function MODULE_views_post_render(&$view, &$output, &$cache) {
if($view->name == 'VIEWNAME') {
if(count($view->result) == 1) {
$output = '';
$cache = '';
}
}
}
For my view field I created a view and am only using the default display. If you have a view with multiple display, you're going to have to add additional logic to make sure you are not removing anything you want to keep.
Comment #5
davidarthur commentedIt should just use the "Hide if empty" option.
Anyone got a better solution yet? I'm looking into it...
(This bug is for v6 release also)
Comment #6
pbeakley commented+1
Comment #7
damiankloip commentedCommitted to dev branch, as per #2, views_embed_view is not being used anymore.
Comment #9
moniuch commentedEven though the issue has been closed, let me chime in.
I got here because I too have been suffering from lack of this 'hide if empty' feature, implemented on the UI side, just like modules are supposed to, without any workarounds. And I was surprised to see the status 'closed (fixed)' - I can't see the feature, so how should I understand that?
Comment #10
damiankloip commentedThis is referring to the Hide if empty checkbox under 'No results behaviour' settings for the field. Where are you looking for this feature? I'm pretty sure it's there.
Comment #11
moniuch commentedI was looking in the Manage Display and Manage Fields form for the content type where I'm inserting the view.
Utilizing the view I'm displaying other categories that a node is tagged with. If there is no other association than the current one, I meant to hide not only the result, but also the label of the view field. I thought the visibility should be controlled on the node level.
The "Hide if empty" checkbox is there in the View but does not cause the label to go off when checked.
Please enlighten me as per the logic you implemented.
Comment #12
damiankloip commentedHang on, you are embedding the view in a node? So you aren't using this module to do it?
Comment #13
moniuch commentedGrrrh.... Looks like I have confused Viewfield with VFV... Will you ever forget? How can I redeem my sin?
Comment #14
damiankloip commentedHa, :) Thought something strange was going on. I will heal over time.....
Comment #15
ice5nake commentedI'd like to see something happen surrounding this request. My take on this was Views Field View is not working correctly with the "Hide if Empty" and "Hide empty fields" View options.
FWIW, I'm using 6.x
Comment #16
damiankloip commentedChanging the issue to the correct version is a good place to start. I would like to see something happen around this too, but unfortunately time is an issue. Most of my concentration is going into the 7.x branch at the moment. Patches are welcome.
Comment #17
jvieille commentedViews field still shows up even if it is empty.
Any solution yet?
Comment #18
fizk commentedThis patch seems to work for me.
Comment #19
fizk commentedNote that I removed the
unset($options[$this->view->name]);in that patch because I needed to access the current view, but a different display.Comment #20
fizk commentedChanged a comment to "// If there are no results and either hide_empty is set or the empty text is set."
Comment #21
jibranDrupal 6 compatible versions of the module are not supported anymore.