How to import a view in Drupal?
Asked Answered
T

6

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.

Tinea answered 28/11, 2011 at 12:4 Comment(2)
What did you use to export the View? I would like to be able to Export and Import Views too.Almshouse
you don't have to be user 1, see below for the permssions your admin role has to have to be able to do thisCullen
H
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
Herren answered 28/11, 2011 at 12:14 Comment(6)
Yes, but for some reason this option is only available for user/1Tinea
@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.Thirzi
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.Isle
At least with Views 7.x-3.3, you also need the "use PHP for settings" permission, according to the views_import_access function.Ladd
It's pretty straightforward people, just append admin/structure/views/import on your www.mysitename.com/ and it would workTagmemic
The module paranoia will disable that url.Carolyncarolyne
T
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

Threedimensional answered 24/7, 2012 at 10:22 Comment(1)
This worked for me, even today on D7. Many thanks.Domesticate
S
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.

Setscrew answered 6/7, 2021 at 9:32 Comment(0)
J
1

For Drupal 6 you would use:

/admin/build/views/import

Jacquettajacquette answered 28/11, 2011 at 12:27 Comment(0)
M
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.

Mercy answered 20/7, 2012 at 15:48 Comment(0)
C
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; }

Cusack answered 24/4, 2016 at 10:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.