How to embed a view in hook_page_build()
The docs say hook_page_build()'s $page variable is for render arrays.

Less obvious from the docs without digging a little further but views_embed_view() returns a string of HTML markup.

So just assigning the result of views_embed_view() to the render array breaks it.

Instead you can use a #markup element.

Because it is the default element type you don't have to specify an element type or theme function or anything, so you can just do this:

/**
 * Implements hook_page_build().
 */
function MODULENAME_page_build(&amp;$page) {
  $page['sidebar_second']['blogs']['#markup'] = views_embed_view('blogs', 'block_2');
}


If that is your entire code for this though (if you don't have some complex logic relating to when this view is being added) I would not recommend adding a block to a region in this manner.

There are lots of options already out there for adding blocs to regions without custom code. For example you could use one of these:


Drupal core block module
Context
Panels