Is there a way to tell if a view will have output?
For example, I created a view which displays summaries of other nodes. I add this to my template using print views_embed_view('view_summary', 'default');
.
That works fine. I want to write some HTML above it, but only if the view has output. If there are no nodes to display, I do not want to write the HTML. I want to display nothing.
How can I report the value of whether the view has an output?
I'm thinking the code goes something like this:
if (views.count('view_summary') > 0) {
echo "<div><h2>Here are some summaries</h2><img src='myimage.jpg' alt='' />'";
print views_embed_view('view_summary', 'default');
echo "</div>
} else {
echo "No result.";
}
Obviously there is no "views.count" function, but what would I do to get the number of results shows in the view?
Any ideas?
Thanks,
Brendan
Comments
SOLVED!
SOLVED! Here's what I did:
You didn't need to do any of
You didn't need to do any of this I'm afraid, the options for including a header are within Views already.
Under "Header":
Choose "Global: Result summary" ~ then there's already an option for "Display even if view has no result" which obviously you wouldn't check.
"Global: Result summary" has a bunch of token replacements you can use for counts of results, hence you could just write;