12

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.

perpetual_dream
  • 1,046
  • 5
  • 18
  • 51

6 Answers6

17

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

VictoriaChan
  • 370
  • 2
  • 5
17

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
Clive
  • 36,918
  • 8
  • 87
  • 113
samir chauhan
  • 1,543
  • 1
  • 17
  • 42
  • 3
    Yes, but for some reason this option is only available for user/1 – perpetual_dream Nov 28 '11 at 12:35
  • @perpetual_dream: It doesn't matter who you're logged in as, what does matter is that the user you are logged in as has the `Administer Views` permission. – Clive Nov 28 '11 at 13:01
  • 3
    I just tested this with a user who has `Administer views` permission. Got the main views paged (i.e. it was falling back to `admin/structure/views`) Tried with it with user1 and it worked. – user151841 Feb 09 '12 at 14:23
  • 5
    At least with Views 7.x-3.3, you also need the "use PHP for settings" permission, according to the views_import_access function. – Matt V. Apr 19 '12 at 22:41
  • It's pretty straightforward people, just append `admin/structure/views/import` on your `www.mysitename.com/` and it would work – nicholaswmin May 26 '15 at 21:27
  • The module [`paranoia`](https://www.drupal.org/project/paranoia) will disable that url. – Felix Eve Oct 29 '15 at 21:58
2

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.

siliconmeadow
  • 123
  • 2
  • 6
1

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.

Jeremy French
  • 11,707
  • 6
  • 46
  • 71
1

For Drupal 6 you would use:

/admin/build/views/import

RoyalFool
  • 246
  • 2
  • 7
0

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; }

AdamS
  • 209
  • 2
  • 8