How can I render a block in the sidebar in php?
If you need to assign block to region programmatically you can implement hook_block_info_alter

function YOURMODULE_block_info_alter(&amp;$blocks, $theme, $code_blocks) {
  if (isset($blocks['views']['name_of_view-name_of_view_display'])) {
    // assign block to region
    $blocks['views']['name_of_view-name_of_view_display']['region'] = 'sidebar_second';
  }
}