简体   繁体   中英

organic group drupal 7 views_get_views

Trying to use views_get_views on the organic groups view OG all user group content to programmatically access the view using php. I am unable to set the parameter properly. I would like to get an example of working call.

Thanks, Olivier

Try This:

/* load view object */
$views = views_get_view('og_all_user_group_content');
/* set default display */
$views->set_display('default');

/* pass group id as argument value */
$group_id =''; //set your group id here
$views->set_arguments(array($group_id));

/* execute view */
$views->execute();

/* result object */
if (!empty($views->result)) {
  if (count($views->result) > 0) {
    foreach ($views->result as $result) {
      //$result contain array of data.
    }
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM