26

I know how to do it in Drupal 6/7, but I cannot find where to export/import views in Drupal 8. From which admin page is possible to do it, in Drupal 8?

21

Views are configuration entities in Drupal 8, and can be exported via the Configuration Management module.

30

Views are available through configuration in Drupal 8, and can be exported via the Configuration Management interface.

In the admin menu select "Configuration" in the DEVELOPMENT section, select "Configuration synchronization": Drupal 8 Configuration Development menu area

In that menu area, the Export tab leads to the path: http://sitename/admin/config/development/configuration/single/export

In that area, a single view can be exported or imported, and the steps are about the same so I'll include Export here to help explain.

  1. Select 'Export' menu tab.
  2. Select 'Single item' sub menu tab.
  3. From the first item drop down 'Configuration type' select 'View'.
  4. From the second item drop down 'Configuration name' select the name of your view.

The result is a views.view.view_machine_name.yml "YAML" file that can be copy pasted into the 'Import' area.

  • Is there a way to do this without the UI? I want to be able to do this from a .module file. – BrandenB171 Jul 20 '16 at 14:21
  • 1
    Yes Drupal Console supports CLI handling of export and import for D8. drupalconsole.com Prior to that, drush has some options. – Adam John Jul 21 '16 at 15:40
  • 1
    Be warned! Improper syntax on the command line for views in drupalconsole can wipe your view. Back up first. – Adam John Jul 21 '16 at 15:42
  • From a .module you will need to look at the hooks used, there are some available for this... You should post a new question in order to follow StackExchange guidance. – Adam John Jul 21 '16 at 15:44
1

If you'd like to export a view for use in the default configuration of a custom module, you can run a Drupal Console command:

drupal config:export:view

See: config:export:view docs page.

protected by kiamlaluno Sep 22 '17 at 4:07

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.