How to get the views datas inside coding in drupal

To get the view datas inside coding , Use the below coding
  
$display = 'page_1'; // 'page_2' or 'block_1' etc
$view = views_get_view('view_name');
$vars['photos'] = $view->preview($display, arg );
$vars['photo_count'] = $view->total_rows;

Note:
arg should be array
arg should he replaced by array($vars['row']->nid) if used template.php file templatename_preprocess_views_view_fields(&$vars) { }

Comments

Popular posts from this blog

PHP - How to increase size of POST value in php

D8 KernelEvents constants

D8 - Attach file programmatically to a node