By darrellhq on
My issue is that I have embedded a view into my page but I need to check that it is empty. I am using this piece of code to do so. Can somebody tell me what I am doing wrong. It seems that if I put the view into a string that no matter what the varible will never be empty. I'm fairly new to php but I can tweak code.
<?php $views_arg = views_embed_view("articles", "block_2", $fields["nid"]->content ); ?>
<?php if ($views_arg == NULL || $views_arg == "") { ?>
<div class="page"></div><ul><li><?php print $views_arg; ?></li></ul>
<?php }; ?>
Comments
Check the result field of the view if empty
The views_embed_view is the easiest way to embed views. It is not too flexible but easily can be broken away. You should do this way:
Thanks. Mine works but your
Thanks. Mine works but your code is really clean and efficient. Just what I was looking for.