I'm running Drupal 8.03 with PHP module added. Other PHP works.
I'm trying to call a view (this is simplified) like this:
===============================
print views_embed_view('view_name', 'embed_1');
===============================
The result? I get a page that says "array" but nothing else. Certainly not the view.
Some version of this worked fine in Drupal 6. Based on other articles, this should work in Drupal 8. What am I doing wrong?
Novice task
Fix the documentation for views_embed_view() so that it contains a @return tag similar/identical to the one in ViewExecutable::preview()
See
https://api.drupal.org/api/drupal/core!modules!views!src!ViewExecutable....
Comments
Comment #2
swentel commentedComment #3
veerasekar89 commentedComment #4
jhodgdonUnfortunately, the views_embed_view() function doesn't have good documentation, as it does not tell what the return value is.
If you look at what the function does, however, you'll see that it creates a ViewExecutable object, and then calls the preview() method on it
https://api.drupal.org/api/drupal/core!modules!views!src!ViewExecutable....
This method returns a render array, not a string. So you'll need to render it.
I'm changing this to a novice documentation bug issue, and adding a note to the issue summary about what we need to do to fix the docs.
Meanwhile... If you need further programming support, please note that although you can create issues in Drupal Core and mark the category as "support request", we don't really handle support requests in the Drupal Core issue queue as a regular practice (that option is mostly there for filing support issues for contributed modules and themes).
There are several support options listed if you click on "Support" at the top of Drupal.org, which will take you to:
http://drupal.org/support
There you can find out about the Drupal IRC channels, and the Forums, which are our two main support mechanisms in the Drupal community. You might also try http://drupal.stackexchange.com/
Good luck with your issue!
Comment #5
borisson_I added the same
@returnas the one inViewExecutable::preview.Comment #6
jhodgdonPerfect, thanks!
Comment #7
dimaro commented@jhodgdon When I apply PHPDoc to autogenerate the comments in views_embed_view(), it shows me three possible values as return values.
array|null|void
We need to include void as return value?
Comment #8
alexpottThis is a kind of duplicate of #2649352: views_embed_view() should use a render array so metadata can bubble up. That patch is changing the render array returned by this function and should add the @return too...
Can someone merge the patches and update #2649352: views_embed_view() should use a render array so metadata can bubble up