Code Snippets

Fix Hard-coded vids, tids and rids in exported views

To fix this problem, refer to the code down below. For more information, refer to this blog post.

define('MYMODULE_MYVOCAB_VID', variable_get('my vocab vid', null));

/**
 * Implementation of hook_views_default_views_alter().
 */
function mymodule_views_default_views_alter(&$views) {
  if (isset($views['view_name'])) {
    $views['view_name']->display['block_1']->display_options['filters']['vid']['value'] = array(MYMODULE_MYVOCAB_VID => MYMODULE_MYVOCAB_VID);
  }
}

 

 

Resource Tags: