Closed (fixed)
Project:
Views (for Drupal 7)
Version:
7.x-3.3
Component:
Code
Priority:
Minor
Category:
Support request
Assigned:
Unassigned
Reporter:
Anonymous (not verified)
Created:
28 Apr 2009 at 01:46 UTC
Updated:
16 May 2024 at 00:50 UTC
Jump to comment: Most recent
Comments
Comment #1
merlinofchaos commentedYou'll need to break apart the views_embed_view function so you can load the view, do the pre_execute() and argument setting, and check $view->result.
Comment #2
Anonymous (not verified) commentedWhat do you mean by 'break apart the function'? Do I need to override it and edit the function code, or do you mean something else?
Comment #3
dawehnerSo this is fixed
Comment #4
Anonymous (not verified) commentedThanks!
Comment #5
Anonymous (not verified) commentedMight be worth noting (for the benefit of others), that
$view->args = array([insert arguments here]);can also be added if needed...Mine wouldn't work without it.
Comment #7
larynI basically recreated views_embed_view with some modifications and saved it in my template.php (called theme_embed_view) so I can call it in my .tpl.php files as needed in exactly the same way I was calling the original function. See below:
Thanks for the help!
Comment #8
steveadamo commentedThanks for the tips in this thread... unfortunately, i have been unable to get the expected return values when trying this code snippet:
my attempts at calling views that i know have results do not display the string... and calling results with no values has a similar effect...
im using 6.x-2.6
Comment #9
dags88 commentedsteveadamo, I had a similar issue, but was able to get the expected results by executing the view as shown on this handbook page: http://drupal.org/node/342132
So my code looks like this:
Comment #10
Michsk commentedthanks saldag8 and others
Comment #11
LEternity commentedThis approach doesn't work if you have "excluded" fields in your view. In that case $view->result still shows them :(. Is there any way that I could filter "excluded" fields?
Comment #12
solona commentedComment #13
knalstaaf commentedHow is this done in Drupal 7?
Comment #14
DjebbZ commentedThe same way than stated in #1, #3 : analyzing views_embed_view (in views.module) and checking if you have any results.
Comment #16
hellomobe commentedI tried to have "no results behavior" return a php variable.
Then I used if(isset($empty)) in the .tpl file. However, regardless of an empty view result, the variable is not returning/available to the view template I'm themeing. Please let me know where I'm going wrong with this approach.
Comment #17
merlinofchaos commentedTemplates do not return values, they print them.
This also doesn't seem particularly relevant to the original issue.
Comment #18
marcopanichi commentedComment #7 works for me, thank you.
I just added "return false;" after the last if statement.
Comment #19
h_dries commented#7 worked for me too, thanks
Comment #20
marcopanichi commented#7 doesn't work with my view, containing a custom field (a common multiple files field "attachments").
It doesn't work because $view->result is an object like this:
PS: in the view edit page, I have only the field "attachments". for test i've added an advanced>no result behaviour text area. but the text area doesn't show, also if the view is empty
Comment #21
easmad commentedI was looking for a solution to check and see if a view had any results. I couldn't get any of the above solutions to work, but I came up with this:
Comment #22
jeuelc commented#21 works for me. thanks eassae!
Comment #23
sanitaM commented#9 worked for me (7.x), thanks!
Comment #24
mahipal46 commented#21 works for me. thanks.
Comment #25
scotwith1t+1 for #21! Thanks.
Comment #26
jo_as_neo commented#21 worked for me (D7.39), thanks !
Comment #27
Tharick commented#21 is perfect :)
Comment #28
themaurice commentedHi, #21 works for me too, thanks. less code is alway better.
Comment #29
erica_hall commentedAnother thumbs up for #21 thank you.