Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rhache’s picture

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

asciikewl’s picture

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

catch’s picture

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.

merlinofchaos’s picture

Agreed, this is on my TODO list.

meppy’s picture

+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.

Grayside’s picture

I'd like a default for each display type.

rupl’s picture

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.

davidneedham’s picture

This would be incredibly useful! Please implement this!

dawehner’s picture

Status: Active » Needs work
FileSize
4.43 KB

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.

Murz’s picture

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.

dawehner’s picture

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

ari-meetai’s picture

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

tsi’s picture

Subscribing

planctus’s picture

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.

frankcarey’s picture

@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.

merlinofchaos’s picture

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.

antiorario’s picture

Subscribing

youkho’s picture

Subscribing

ds1964’s picture

Subscribing

upupax’s picture

Subscribe

GiorgosK’s picture

+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"

planctus’s picture

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

AdrianB’s picture

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

redpuma’s picture

Subscribing and +1

rfay’s picture

+1

DomoSapiens’s picture

+1

davepoon’s picture

Waiting for this feature on the next release.

rfay’s picture

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.

greg.harvey’s picture

Did anyone ever try the patch in #9?

dawehner’s picture

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

greg.harvey’s picture

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

nikodev’s picture

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 !

bluestarstudios’s picture

+1

cpall’s picture

+1

YK85’s picture

+1 subscribing

Grayside’s picture

@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.

cpall’s picture

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.

scottrigby’s picture

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

crea’s picture

Subscribing

pbeakley’s picture

+1

elizarraraz’s picture

+1

drawk’s picture

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

ndm’s picture

+1 Very usefull feature

anyr’s picture

subscribe this would be awesome

AdrianB’s picture

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.

dawehner’s picture

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.

AdrianB’s picture

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.)

dawehner’s picture

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

scottrigby’s picture

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 ?

dawehner’s picture

FileSize
5.97 KB

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.

dagmar’s picture

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?

dagmar’s picture

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

dawehner’s picture

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 :)

ndm’s picture

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

Good day

q0rban’s picture

subscribe. :)

MatthijsG’s picture

And another subscribe (sorry ;-P)

bachbach’s picture

+2 :D

dawehner’s picture

Status: Needs work » Needs review
FileSize
7.63 KB

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.

MatthijsG’s picture

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

rfay’s picture

Jukebox’s picture

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

dawehner’s picture

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

scottrigby’s picture

@dereine - I will def test & report back asap

scottrigby’s picture

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!

Bilmar’s picture

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

rfay’s picture

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.)

Bilmar’s picture

@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?

AdrianB’s picture

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

Bilmar’s picture

FileSize
7.04 KB

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.

dawehner’s picture

@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.

HedgeMage’s picture

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.

rfay’s picture

@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.

dawehner’s picture

Status: Needs work » Needs review

Update

HedgeMage’s picture

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

drifter’s picture

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

geerlingguy’s picture

Status: Reviewed & tested by the community » Needs work
FileSize
38.44 KB

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!]

rfay’s picture

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

q0rban’s picture

Status: Needs work » Reviewed & tested by the community

Worked great for me! woohoo!

q0rban’s picture

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".

xmacinfo’s picture

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!

dawehner’s picture

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.

ianchan’s picture

subscribe

bloke_zero’s picture

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!

ndm’s picture

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

Thanks for your works

SeanBannister’s picture

Sub

Fabianx’s picture

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)

dawehner’s picture

@Fabianx

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

Pasqualle’s picture

@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..

Danny Englander’s picture

Subscribing

dawehner’s picture

@pasqualle

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

likewhoa’s picture

Subscribing and will test on 3.x

WAKeaney’s picture

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?

dawehner’s picture

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.

geerlingguy’s picture

@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.

greg.harvey’s picture

+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...?

dawehner’s picture

*push*

Danny Englander’s picture

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

dawehner’s picture

One word:

awful

TravisCarden’s picture

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!

jahmekyat’s picture

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.

TravisCarden’s picture

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!

Grayside’s picture

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?

eaton’s picture

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.

dawehner’s picture

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.

dawehner’s picture

FileSize
6.95 KB

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.

merlinofchaos’s picture

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

dawehner’s picture

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.

dawehner’s picture

FileSize
8.83 KB

I used this fix.

devilhoused’s picture

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

devilhoused’s picture

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.

BeaPower’s picture

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

devilhoused’s picture

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

xjm’s picture

#108 works great for me.

merlinofchaos’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)
FileSize
9.25 KB

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.

dawehner’s picture

Status: Patch (to be ported) » Needs review
FileSize
8.83 KB

Here is a patch.

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

tlangston’s picture

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

MatthijsG’s picture

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

dawehner’s picture

It's not the same size.

The patch i posted it for drupal 7.x

dawehner’s picture

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.

Status: Fixed » Closed (fixed)

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

bleen’s picture

+++ 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.

Danny Englander’s picture

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.

dawehner’s picture

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

Danny Englander’s picture

@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.

dawehner’s picture

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.

xjm’s picture

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.

Danny Englander’s picture

@ 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!

ari-meetai’s picture

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

dawehner’s picture

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

N4R4YAN’s picture

is there a patch for drupal 6?

Danny Englander’s picture

@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

liquidcms’s picture

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)

xjm’s picture

liquidcms’s picture

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. :)

liquidcms’s picture

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

antiorario’s picture

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

Danny Englander’s picture

I don't see it in Views 2.12 either.

merlinofchaos’s picture

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

antiorario’s picture

That is wise advice…

liquidcms’s picture

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

antiorario’s picture

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 :-)

liquidcms’s picture

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). :)

koppie’s picture

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?

xjm’s picture

#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.

candelas’s picture

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 :)

xjm’s picture

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

GiorgosK’s picture

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

candelas’s picture

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.