Download & Extend

Add the Ability to Clone a Display

Project:Views
Version:7.x-3.x-dev
Component:User interface
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

A time-saving feature would be the addition of display-cloning functionality within a view.

Comments

#1

+1 from me on this one. While cloning a view is useful, cloning a display would be even better.

#2

subscribe

And +1 from me! I love the ability of keeping everything in one view, but some of my displays override quite a bit and re-creating that for new displays is a schlep.

Anton

#3

I was thinking this would be a handy thing for a while, but then I decided I should be making separate views instead. If it's easy to do, would be a nice feature though.

#4

Agreed, this is on my TODO list.

#5

+1 for me here, although if the default view is setup well then it's not a huge problem. A workaround if you have several displays that differ from default in the same way then set the default to match, then override each part you need to, then change the default for the next batch, etc.

#6

I'd like a default for each display type.

#7

Being able to clone a display would be delightful. In cases where you want to create several similar blocks it would save time and help eliminate human error.

It seems like it would be even harder to implement, but as Grayside mentioned, a default for each display would be even more powerful and flexible.

#8

This would be incredibly useful! Please implement this!

#9

Status:active» needs work

Here is an initial patch.

It works perfect if you disable js. But if i have js enabled, its basically doubles the copies, but disables the previous display.

But it needs quite some stuff etc.

AttachmentSizeStatusTest resultOperations
views-clone.patch4.43 KBIgnored: Check issue status.NoneNone

#10

This is very needed for me too, waiting for working patch.
But maybe not so good to create many displays (with many changes) for one view, better to do different views? What about performance in this variants, which variant is more speedy?
I thing when views loads the view, it loads and analyze all displays for show only one display.

#11

Thats a really good question. I know that views does quite a lot of stuff in unpack_options.

#12

+1. That Merlin has it already on the TODO sounds terrific. :)

#13

Subscribing

#14

Cool...i was looking for this
Go coding merlino... :-)

This is really crucial in multilanguage website making,
since it is not ready yet i'm going to clone the whole views, it will be easier but a little bit silly...
Thanks,
Da.

#15

@merlin is there a simpler way to do this in code first? I'd like to get features module to be able to add displays, not just whole views.

#16

frankcarey: Adding displays could be done via hook_views_default_views_alter() I think, but that will only work if the view is already in code.

#17

Subscribing

#18

Subscribing

#19

Subscribing

#20

Subscribe

#21

+1 for this feature

@planctus you don't necessarily need to copy a display in order to create the same display per language
have you tried "Node translation: Language > Current user's language, filter"

#22

You're perfectly right... i noticed that after commenting this issue. :-)
Da.

#23

I guess another +1 is pointless at this point, but I'd like to subscribe anyway, so here's my +1.

#24

Subscribing and +1

#25

+1

#26

+1

#27

Waiting for this feature on the next release.

#28

Actually, we probably all want two things.

What we probably *really* want is to be able to inherit settings from more than just the default display. Would it be easier to do that? Because that would be still more powerful.

But we'd be happy to be able to clone displays as well to accomplish the same goals.

#29

Did anyone ever try the patch in #9?

#30

i Would not, unless you are a developer. I will post a new version in some days, which works much better.

#31

I am, but I'll follow your advice anyway and await the new patch. Thanks! =)

#32

Manual Alternative.
You can export the view, duplicate the displays inside text exported (with different display names of course), remove the original view, and then import the new one (with displays duplicated).
Dont forget to save the new version of this view.

Done !

#33

+1

#34

+1

#35

+1 subscribing

#36

@nikohk, the manual approach in #32 might be useful for especially complex Views, but it's still an awkward and time-consuming solution compared to pressing a button. For somewhat simple views, for which this is a low-priority but still helpful feature, it is still faster to replicate the view in the UI.

Not to mention imposing the sight of code on non-developers that have become adept with the Views interface.

#37

Grayside: Totally the point of this. I've got a display I'm looking to "duplicate" that has about 20 some odd fields, some of which are php eval() field which do conditional type displaying. Add into this about 7 filters, and I just hate the idea of manually trying to sort through the some odd 15 other displays that happen to exist in this view. I think where I "went wrong" was I should probably just maintain these as separate views, but that has it's own drawbacks.

#38

@dereine - i'm down with test driving the new patch - signin' up

#39

Subscribing

#40

+1

#41

+1

#42

Essentially just subscribing. +1, this would be really handy and makes a lot of sense.

#43

+1 Very usefull feature

#44

subscribe this would be awesome

#45

I find myself creating multiple views instead of multiple displays just because of the awesome clone feature. And in Panels I use it a lot to clone variants and it works really well. I'm not trying nag about this feature, just saying that it is incredible helpful when it exist.

#46

Sure everyone knows that this would increase the productivity a lot. I don't understand why so many people are making a subscribe/+1. comment, this floods peoples mail account.

#47

I don't understand why so many people are making a subscribe/+1. comment, this floods peoples mail account.

Because unfortunately there's no other way to subscribe to an issue?

Since this is a wanted feature a lot of people want to keep an eye on the development of this issue (and, at the same time, show that there's an interest for this feature). I know some prominent committers consider subscribing a rude selfish act, but that's just the symptom of a bad system and should be fixed instead of blaming people for wanting to subscribe.

(Yeah, I know that the Drupal answer is "if you want something, code it" but not all people know enough to add a feature like this to a complicated module like Views.)

#48

Sure i know this, i don't like the situation. My comment was kind of ironic.i checked my d.o subscriptions account and the count was 1600 unread emails :) I cannot imagine why people subscribe freely ;)

#49

here r Derek's thoughts: "Death to "+1 subscribe" comments: Help needed" http://3281d.com/2009/03/27/death-to-subscribe-comments

for anyone else interested to subscribe to Views project issues - there is a way:
Log into d.o & go to http://drupal.org/project/issues/subscribe-mail/views & select all issues
(if you want to subscribe to all 8200 issues / 1200 open issues in the Views queue that is ^_^)
btw, some new functionality *is* still being added, as part of the d.o redesign a lot of folks here are testing... things r still moving a little slowly there, so - if anyone's interested to help add a "subscribe" feature, it seems plausible 2 me it could make it in :) Just sayin'

In any case... back to this clone views display issue...
@dereine, what would be the best way for people interested in this thread to help ?

#50

I think the best thing is to post a new patch :)

Stuff which needs to be done:

  • If you click the clone button, there should be a redirect to the view, but this does not happen. Perhaps someone can figure out why:
    // $form_state['redirect'] = array('admin/build/views/edit/' . $form_state['view']->name, NULL, 'views-tab-' . $new_id);

    This should redirect but it does not.
    It works fine for me after f5 views, this means that the cloned display is working.
    Thats the reason why its on NR
  • Test whether add settings of the old display is copied correct. (overriden values, non-overriden value)

Additional todo:

  • Write documentation: This shouldn't be a lot.

Thats basically it.

PS: I suggest to everyone using +1 to give some money for the chipin.

AttachmentSizeStatusTest resultOperations
views-clone-display.patch5.97 KBIgnored: Check issue status.NoneNone

#51

Mmm I didn't test this patch yet, but.

+  $form['#action'] = url("admin/build/views/nojs/clone-display/$view->name/$display_id");

We should define this menu in views_ui_menu() isn't?

#52

Forgot my last comment, is too late for review views patches today :)

#53

Just for other people, who wnat to know this

This get catched by

$items['admin/build/views/%views_ui_js/%/%views_ui_cache'] = $callback + array(
    'page callback' => 'views_ui_ajax_form',
    'page arguments' => array(3, 4, 5),
  );

dagmar: Sleep well :)

#54

For me it's work just the problem with the redirect.

Good day

#55

subscribe. :)

#56

And another subscribe (sorry ;-P)

#57

+2 :D

#58

Status:needs work» needs review

puh!

thats the first version which works as i expect it. I would like many people to test it out, find bugs and review code.

AttachmentSizeStatusTest resultOperations
views-clone-display.patch7.63 KBIgnored: Check issue status.NoneNone

#59

I want to test it, but i never find a good tutorial how to use patches. How can i attach the patch?

#60

#61

here's my +1 ... would be a useful feature.

#62

Can someone test this patch :) You all subscribers, you get this mail, i know it

#63

@dereine - I will def test & report back asap

#64

ran patch against 6.x-2.x-dev, and had an offset of -4 lines on the last file, but otherwise applied perfectly clean on all other files

I've been test driving it as well - mainly on node type views... so far so good!

#65

Hello,

Very cool new feature! The patch applied smoothly with 6.x-3.x-dev (April 18, 2010). I tested Clone display with node and user type views and with block, page and content pane displays. The display was copied perfectly and the machine name was set as the next number for the display type. All the blocks displays and exposed filters as a block were available at the Blocks settings page.

I noticed after testing that the version of this thread was set to 6.x-2.x-dev, but hope to see this feature in views 3 =)
Hesitating to set status to RTBC because of the difference in version I am using, but everything worked great!

Regards

#66

A casual test worked fine for me (patched views-6.x-2.10 with #58).

One note for testers: You have to rebuild the menu router after doing the patch. If you get a 404 error when testing, it's because you didn't do this. You can either clear all caches on admin/settings/performance or rebuild the menu router any other way.

+1

(But I'd still *really* want to be able to inherit settings from more than just the default display. That would be still more powerful. But the user interface probably isn't as simple.)

#67

@rfay - in regards to your last comment, I am able to click on a display that is not the default display (completely different setup) and clone it without an issue. Is this what you are referring to?

#68

trupal218: I think rfay means that one display (not default) would be able to inherit settings from another display (also not default).

#69

ahh I see - I guess that's a different feature request from Clone Display? I agree it would be cool to have in Configure fields (for sections that have been overridden) buttons other than Use default for the other displays.

AttachmentSizeStatusTest resultOperations
configure fields.png7.04 KBIgnored: Check issue status.NoneNone

#70

@trupal218

Yes thats definitive another feature request. I thought there would be already be a case, but as far as i understand the code, its not so easy to implement.

#71

Status:needs review» needs work

Applied #58 against 6.x-2.x-dev (from CVS a few minutes ago), it doesn't work...clicking the button gives a popup stating "An error occurred at /admin/build/views/ajax/clone-display/drafts/page_1. Error Description: 404: Not Found" (I tried to clone the page display of the view 'drafts'.)

I took a pass at figuring out why it worked for rfay and not for me, but I think it's beyond my views-fu.

#72

@HedgeMage: You have to clear the menu router cache. I had the same thing.

Anybody who tries this patch: After applying, you have to clear the menu cache. #66 tells how.

#73

Status:needs work» needs review

Update

#74

Status:needs review» reviewed & tested by the community

@rfay -- Thanks...can't believe I forgot to clear the cache! (And no wonder staring at the code gave me no clue what was broken...it wasn't.)

Marking RTBC

#75

Tested patch #58, works for me, second that RTBC.

#76

Status:reviewed & tested by the community» needs work

I just tried it with views 6.x-2.10, and it's not working (see attachment).

[Edit: w/r/t the post below, clearing the menu router cache fixed the 404 error. Thanks!]

AttachmentSizeStatusTest resultOperations
clone-display-404.png38.44 KBIgnored: Check issue status.NoneNone

#77

Status:needs work» reviewed & tested by the community

@geerlingguy, everybody has this problem. Please see #66 and #72. Please clear your menu router cache and test again.

#78

Worked great for me! woohoo!

#79

Only recommendation would be to add the word "Copy" to the Name of the display. So, if you have a display called "Nifty Block", and then clone that display, the cloned display would be named "Nifty Block Copy".

#80

What is the status of this patch? Any chance to see this on 6.x-2.x-dev or a new release?

This will indeed be a great time saver!

#81

I think you see the status of the patch:)

Any tests help, i think thats clear. Additional some real code reviews would be fine, too.

#82

subscribe

#83

It's not to difficult to do via phpmyadmin

Export the display as a text file, change the following fields `id`, `display_title`, `position` - save and import - presto! Always back-up first!

#84

Second test and always works fine for me, better than the older.

Thanks for your works

#85

Sub

#86

Hi,

+1

Tested patch #58, works for me, second that RTBC.

--

Feature request: Be able to choose another type for the new display:

Clone Page to Block for example.

Best Wishes,

Fabian (LionsAd)

#87

@Fabianx

This does not make sense for me. A different display might be totally different settings.

#88

@dereine: clone to different display type: transfer the settings which make sense in the new display, use defaults for the rest. but anyway, it is a new issue..

#89

Subscribing

#90

@pasqualle

This might be possible but could might be lead to other problems, i think this has to be another issue, definitive.

#91

Subscribing and will test on 3.x

#92

I have to admit I was really excited to see this patch.
However, in practice it doesn't seem to do what I was expecting. I would like to be able to clone Displays between different Views.
Does this patch enable that, or am I missing something?

#93

No this patch does not do this and it's not intended to do it.

In theory it would be possible but from my perspective this is a very confusing option.

#94

@WAKeaney / #92 - I agree with dereine on this; it would not only be confusing, but very hard to find a way to make it easily understandable from a UX perspective.

#95

+1, just cloning displays in a View is a big win and a time-saver - if you want to clone a display to another view, either clone the View and delete the displays you don't need or, if the requirements are so similar, ask yourself why they're different Views in the first instance...?

#96

*push*

#97

Has anyone tried this? 'Views clone display' http://drupal.org/project/views_clone_display

#98

One word:

awful

#99

As long as there's disagreement as to the merit of whole idea of the feature, I'll add my two cents: I highly support the addition of a "Clone Display" feature. I wish for it almost daily. I realize it may be difficult to accomplish well from a UI perspective, but I feel the benefit of it outweighs the difficulty. It would be a convenience, to be sure, but also a safeguard from copy errors and omissions—there are a lot of settings to remember (or forget!) if you're duplicating a display by hand!

#100

I could see myself using this feature on a daily basis. If I was capable of programming this patch at this time, I would do it myself. The ability to clone any previously created display type should be built-in to views. I could see this feature update speeding up my job duties considerably.

#101

Title:Clone a display» Add the Ability to Clone a Display

if you want to clone a display to another view, either clone the View and delete the displays you don't need or, if the requirements are so similar, ask yourself why they're different Views in the first instance...? - @greg.harvey (#95)

Another use case to consider is reorganizing or refactoring Views. Suppose, for example, you have two Views that you realize are so substantially similar they should just be one View. How much simpler it would be to clone the displays from one into the other than to duplicate them by hand!

#102

Let's get cloning displays within a View settled first. Cloning a display between Views sounds like a next step, and it's a scope expansion that has already distracted from the fact that the patch in #55 appears RTBC for Views 2.

What more needs to be done to get this committed?

#103

This is is way more convenient than exporting the view, hand-duplicating one of the displays in a text editor, deleting the View, and re-importing it.

Seriously.

#104

What more needs to be done to get this committed?

The maintainer just have to download the patch and apply it and commit it with cvs :)

It does not help if people continues answering it's a cool features. This is sure :)

As you see in the commit messages, some patches got commited already, so it might be time for it, too.

#105

Obvious you trust me. I'm sad about it.


+  function generate_display_id($type) {
+    // You can't clone the default display.
+    if ($type == 'default') {
+      return FALSE;
+    }
+    // Initial id.
+    $id = $type . '_1';
+    $count = 1;
+
+    // Loop through IDs based upon our style plugin name until
+    // we find one that is unused.
+    while (!empty($this->display[$id])) {
+      $id = $type . '_' . ++$count;
+    }
+
+    return $id;
+  }
+

As you see this function is not used anywhere :)

The test still does makes sense, because it tests the generation of new display id's of the add_display method.

AttachmentSizeStatusTest resultOperations
views-clone-display_0.patch6.95 KBIgnored: Check issue status.NoneNone

#106

That's a useful method and it *should* be used. =)

#107

I would vote personally to make a new issue to get this abstracted function in. There are some issues for example

      // we find one that is unused.
      while (!empty($this->display[$id])) {
        $id = $type . '_' . ++$count;
        if (empty($title)) {
          $title = $plugin['title'] . ' ' . $count;
        }
      }

I would need to find a way to generate the title. I guess a str_replace($type . '_', '', $id) could work for the count.

#108

I used this fix.

AttachmentSizeStatusTest resultOperations
views-clone-display_0.patch8.83 KBIgnored: Check issue status.NoneNone

#109

This is an excellent thread about a very desirable patch to Views, thank you. Haven't gotten to try it out yet though. Any chance in this working for Views 6.x-2-11? I cannot seem to locate 6.x-2.x-dev at this time... Thanks.

--
dev

#110

I still have not gotten this patch to apply correctly it seems (on 6.x-2.11) even though I am receiving no errors at command-line (I used -p0 and succeeded but realize this is not a core patch and did not truly apply). I am determined to do this.

edit: The patch applied fine and I did have to use '-p0' after all.

#111

Please add this to the next module release as I don't know how to apply patches, thanks

#112

For BeaPower and others who are learning to apply patches (especially to Drupal), refer to the 'Applying patches' guide. Procedures may vary depending on your system, but that covers them. The URL is provided at the bottom of this message as well. Like I said before, for this patch I used the -p0 flag to successfully patch root. Some patches must be applied to root and I guess this is an example of such case. It will make sense once you've read the primer and tried it out. Read carefully and good luck.

Applying patches - http://drupal.org/node/60108

#113

#108 works great for me.

#114

Version:6.x-2.x-dev» 7.x-3.x-dev
Status:reviewed & tested by the community» patch (to be ported)

Committed to 6.x-2.x and 6.x-3.x after a quick test.

Note that I had to add a line to prevent a notice from being fired as the default display does not have a clone button and the template generated a notice trying to render it. Actual patch (to 2.x) attached.

AttachmentSizeStatusTest resultOperations
348975-clone-display.patch9.25 KBIgnored: Check issue status.NoneNone

#115

Status:patch (to be ported)» needs review

Here is a patch.

The problem is that the cloning does not work via ajax.

AttachmentSizeStatusTest resultOperations
348975-clone-display.patch8.83 KBIgnored: Check issue status.NoneNone

#116

Worked like a charm! You just saved me a boatload of work:) Thanks!

#117

What is the difference between #114 and #115? Same number, different size :-?

#118

It's not the same size.

The patch i posted it for drupal 7.x

#119

Status:needs review» fixed

I think it's worth to commit the patch in it's current state. The remove display button also does not work without a reload. So let's fix this is another issue.

#120

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#121

+++ includes/admin.inc 14 Aug 2010 06:18:12 -0000
@@ -1777,6 +1779,86 @@ function views_ui_add_display_form_submi
+ * From to clone a display from a view.

I should probably open a new issue ... but i noticed a typo in the patch that was committed: *form* not *from*

Powered by Dreditor.

#122

I am just curious, I am using views 2.11 for Drupal 6 from June 17th, 2010 and comment #114 above says "Committed to 6.x-2.x". What version of 2.x should I use to have this functionality? I do not see a newer dev version of 2.x. thanks.

#123

You can access any release on http://drupal.org/node/38878/release

#124

@dereine, yes but the newest version of 2.x is from June 17, 2010. Comment #114 above says "Committed to 6.x-2.x" but I do not see a version for 2.x newer than June 17th, not even a dev version.

#125

Download the latest version and you will see it's there. The date is the date when the release-node was updated/created the last time.

#126

Direct link to 6.x-2.x-dev:
http://drupal.org/node/95897

Not sure why the dev builds are no longer on the project page, but that's where I've been getting it. You'll see that the post date is when it was first added, but it also shows it was updated Oct 15 2010.

#127

@ xjm - thanks, that link worked, exactly what I needed. I updated and now see the clone display button in my views. Indeed 2.x dev is not listed on the project page. Clone Display FTW!

#128

it worked fine here too. is it possible to reorder displays too?

#129

@arielon
IN views3 yes but not on drupal7 yet. There is another issue :)

#130

is there a patch for drupal 6?

#131

@N4R4YAN At least for Views 2.x - No patch needed, see the link above in #126. That one works, for some reason it did not make it to the project page yet. I can't vouch for the 6.x - 3.x version as I am still using Views 2.x

#132

just a warning.. and mostly to subscribe.. the latest dev version of Views 2.x has broke "output this field as a link" so i wasn't able to use that rev to get the very cool "clone a display" feature.

also, not sure what rev the patch in #115 is against (doesn't apply to latest released version of Views: 6.x-2.11)

#133

#134

ahh cool.. was mostly worried dev had other issues but a patch to fix that will definitely have me using dev again since cloning a display is a huge addition.

thanks for pointing out link to patch. :)

#135

hmm.. except i guess patch from #133 is on 3.x and not 2.x

#136

Wasn't this committed to Views 2? It doesn't seem to be there in 2.12.

#137

I don't see it in Views 2.12 either.

#138

#136, #137: Reading release notes is highly recommended.

#139

That is wise advice…

#140

i think (but wouldn't swear to it) that what merlin is saying is that since rel notes for 2.12 (and i guess going back through the rest of the releases) doesn't show "add clone ability" so it likely isn't there. The only place i was able to get this for 2.x was the latest dev which i pulled a few months back.

but.. oops... i saw a security update for View so was silly enough to update. so i lost clone ability. so went and grabbed lastest 2.x dev rel and it is busted (can't save a view) so i think at the moment; no way to get cloning in 2.x

#141

i think (but wouldn't swear to it) that what merlin is saying is that since rel notes for 2.12 (and i guess going back through the rest of the releases) doesn't show "add clone ability" so it likely isn't there.

I know. I wasn't being sarcastic: I did think it was wise advice :-)

#142

ok, my comment about latest 2.x-dev not working may simply be a caching issue... latest -dev wouldn't save new views.. just goes to page not found... so i went back to older -dev version that i know is working on another project and i was seeing same issue.

i cleared all caches and seems to be working now.. so most likely the latest 2.x-dev is working as well (and likely has display cloning ability). :)

#143

So, this patch has been in 2.x-dev for almost a year now, several stable versions have been released in that time, and this patch still hasn't made it into a stable version? There's another project out there, http://drupal.org/project/views_clone_display, that seems to do the same thing and claims it's stable. I'm a little hesitant to load a development module into a production environment.

So, any recommendations from the community? Is it better to use the dev version or install a third party add-on module?

#144

#143: 6.x-2.x hasn't seen a new release in a long time because of a number of outstanding NR and RTBC issues, as far as I understand. I'm running off 6.x-2.x-dev in production and it's been a mixed experience. One safe thing would be to take 6.x-2.12 and just apply the patch from #114.

#145

subscribe :)
i go to use http://drupal.org/project/views_clone_display but i think it would be nice if it can be inside views.
thanks for the module and the multiple patch in this page :)

#146

#145: It is in views. Install the dev build or apply the patch from #114.

#147

#145
latest dev of views 6.x 3.x has functionality included

#148

thanks Giorgosk
now i am finishing a web and i have views 6.x.2.x and i have solved the problem with the module views clone display
next site, i will use views 6.x.3.x or 7.
thanks a lot for giving us this exceptional tool.