Of course I could copy one by one all fields and settings that the master becomes exactly the same, but isn't there an easier way? In a display there are three options:

  • This page(override), the present setting of the display
  • All displays
    when I use it will mess up my display. For instance in a field it removed all other fields in the display. Not a solution.
  • refert to default
    which will mess up my display too.

So what is the way to do this besides doing it by hand? May be there is contributed module for this?

Comments

technikh’s picture

+1 looking for same thing

Cheers,
TechNikh

In 30 seconds set up Automated Visual testing of your website. Zero coding. https://drupal.org/project/drulenium
Ever dreamed of styling your view, We have a solution for you. https://drupal.org/project/views_stylizer

nithinkolekar’s picture

no following here?
+1 subscribe...

nwom’s picture

Looking for the same thing myself. Can't seem to find an answer thus far.

jedihe’s picture

It is possible to transfer all the overrides from a display to the master display of a View by running a PHP snippet in /devel/php (provided by Devel module). Of course, make sure you save an export of the original view before trying this out since I can not guarantee it will work perfectly for every View.

The template for the snippet is this:

$view = views_get_view('machine_name_of_my_view');
$source_display = 'machine_name_of_the_overridden_display';
dpm($view, 'view');

foreach (array_keys($view->display[$source_display]->display_options['defaults']) as $key) {
  if (!empty($view->display[$source_display]->display_options[$key])) {
    $view->display['default']->display_options[$key] = $view->display[$source_display]->display_options[$key];
  }
  unset($view->display[$source_display]->display_options[$key]);
}
unset($view->display[$source_display]->display_options['defaults']);
dpm($view, 'new view');

// Uncomment and run once you are sure to save the changes.
//$view->save();

Just make sure to replace "machine_name_of_my_view" and "machine_name_of_the_overridden_display" with the correct values for your use case. The last line is commented in order to allow inspecting the output of the two dpm() calls to make sure the new view will be set as expected; once you feel confident about the result, save an export of the view, un-comment the last line and re-run the snippet.

starcruiser’s picture

Thanks jedihe!!!

liquidcms’s picture

awesome.. thanks.

tvb’s picture

Thanks!

lhugg’s picture

This still works like a charm! Just used with a Views 7.x_3.15 version of Views.

grincon’s picture

Drupal views version 7.x-3.24, worked like a charm, Thanks!

web226’s picture

Thanks @jedihe worked perfectly for me with Views 7.x-3.18 and Devel 7.x-1.5 with Drupal 7.56

ckaotik’s picture

This problem still exists in Drupal 8 today, for which I've created an issue + patch for anyone interested: #2907995: Views UI sometimes fails to set overridden display to "All displays"

mihai_brb’s picture

From my understanding the question is How to copy all display options from a display to master.

In my case I did it with:

1. Export the view.

2. Locate the section where my correct display options are. In my case they where below $view->new_display('page', 'Page-name', 'page');

3. Copy the section of $handler->display->display_options

4. Paste them below Display: Master - $handler = $view->new_display('default', 'Master', 'default'), replacing the existing display options

5. Import the view.

6. Delete the old view.

I hope this helps.

kristinec’s picture

This worked for me on 7.72. Thanks so much!