12
votes

How I can Import a view to Drupal. I have an exported view that I need to import in a different Drupal Installation. I don't have an import option in the admin/structure/views?

Thanks!

Edit:

I have found the solution. I have to log in as user 1 to get this option.

6
What did you use to export the View? I would like to be able to Export and Import Views too. - therobyouknow
you don't have to be user 1, see below for the permssions your admin role has to have to be able to do this - Diana

6 Answers

17
votes

There is a import option in the views listing page. Just paste this url after your current url and you will see the import views page. By seeing your tags I am assuming you are using Drupal 7, so the given below url will work only for Drupal 7.

Below is the url to be added :

#overlay=admin/structure/views/import
16
votes

For D7, if you don't want to use user #1, you can enable the 'PHP filter' core module, and then give the relevant user role the 'Use PHP for settings' permission. Users with this role will then see an 'import' link next to the 'Add new view' link on the views admin page. Or you can go to the import page directly on /admin/structure/views/import

2
votes

I have just discovered another reason this can happen - the Paranoia module being enabled. If enabled, /admin/structure/views/import will display "You are not authorized to access this page", even if you are logged in as UID1.

Cool module. If it's enabled, you won't see it in the admin interface, even if you're logged in as UID1. You'll need to disable it with drush dis paranoia or setting the status of it to 0 in the system table.

1
votes

For Drupal 6 you would use:

/admin/build/views/import

1
votes

User 1 works as you have all permissions checks set to true.

To enable this for other users you need to enable the php module and make sure your user has the "use PHP for settings", this is a setting that should only be given to trusted users as it allows pretty much anything to be done on your site. Which is what happens when importing a view. For more info see this thread.

0
votes

Anyone who prefers to run a locked down site may have chosen to disable user 1 (avoid risk that the password is guessed) and disable the PHP module (for example site policy is to avoid using PHP input filter).

If you are comfortable writing a php hook in your custom module, you can do this (taken from php.module):

/**
 * Implements hook_permission().
 */
function XXX_permission() {
  if (!module_exists('php')) {
    return array(
      'use PHP for settings' => array(
        'title' => t('Use PHP for settings'),
        'restrict access' => TRUE,
      ),
    );
  }
}

return $permissions; }