1.20.x views.install views_update_1004()

Replace the frontpage view with promoted.

Related topics

File

modules/views/views.install, line 132
Contains install and update functions for Views.

Code

function views_update_1004() {
  // If the old frontpage view is still disabled, delete it.
  if (config_get('views.view.frontpage', 'disabled') === TRUE) {
    $config_frontpage = config('views.view.frontpage');
    $config_frontpage->delete();
  }
  // See if there is already a promoted view on this site.
  $config_promoted = config('views.view.promoted');
  if ($config_promoted->isNew()) {
    // If not, create the new promoted view and mark it disabled.
    $path = backdrop_get_path('module', 'node') . '/config/';
    $contents = file_get_contents($path . 'views.view.promoted.json');
    $data = json_decode($contents, TRUE);
    $config_promoted->setData($data);
    $config_promoted->set('disabled', TRUE);
    $config_promoted->save();
  }
}