Assume you used Views to build a page display (in Drupal 7). So you have the typical "master", and an additional display called (let's say) "MyPageDisplay". And assume that in this "MyPageDisplay" you "overwritten" various settings (fields, sorting, whatever) from your "master".

And then you want to create a block display that's exactly the same (same filters, etc) as the "MyPageDisplay". There doesn't seem to be any facility to copy or clone such "MyPageDisplay"-display.

How can you duplicate a Views display like "MyPageDisplay" as a different display type in D7? And is there any type of improvement in Drupal 8 about this?

  • That makes it more reasonable. Your answer about Drupal 7 / Views 3 is still incorrect. There are ways to do this. I only know the ugly ways, which I don't have time write up. – mpdonadio Feb 20 '16 at 20:08
up vote 3 down vote accepted

Drupal 7 solution

There is no out-of-the-Views-box solution for this in Drupal 7 ... Except if you get really creative (or via "ugly ways" as @MPD wrote in a comment below the question) with exporting / editing / reimporting such view. But that's not out-of-the-Views-box of course, and to my knowledge not included somewhere within the Views UI. Comment #1 in the issue about "Clone a Page view into a block view" seems to confirm this.

Drupal 8 solution

In Drupal 8, for an existing display of a view, assuming it's a page display, you can say "duplicate this display as another display type". This will copy all of that view definition to the new display.

As an example, in a standard (core only) Drupal 8 site, you can now duplicate a page display as:

  • another page.
  • a block.
  • an attachment.
  • an embed (1).
  • an entity reference (2).
  • a feed.

This appears to be one of the most exciting new features of Views in Drupal 8 ... Apart from Views in Drupal Core (= VDC) ... of course.

Notes:

  • (1): In the Views settings, if you select “Allow embedded displays”, then they can be used in code via views_embed_view().
  • (2): In the Entity Reference field settings, select “Filter by an entity reference view” and use a view with this display type to define what can be referenced.


Credits: "Babou", who made me discover it while listening to "Talking Drupal (episode 111)".



  • Downvoting this answer as it is incorrect. There are ways to accomplish this. – mpdonadio Feb 20 '16 at 19:53
  • @MPD: please check my refined question. Are you sure there are ways to accomplish this in D7 (except using things like I wrote in my "except" phrase)? – Pierre.Vriens Feb 20 '16 at 20:08
  • Nobody likes downvotes (I assume), neither do I. But if they are from someone who cares to leave a comment to explain the downvote (as suggested in the famous blue box after downvoting), then I really don't have a problem in "accepting" such downvote. Because it is like an opportunity to learn from mistakes. In this case, I translated it to like "hm, looks like I need to better explain my question, and edit my (own) answer", which I just tried to do. Up to you (@MPD) now to eventually reconsider your downvote (which you can, now that I edited my answer, right?). No obligation of course ... – Pierre.Vriens Feb 20 '16 at 20:33
  • I left a reason for the downvote on both the question and answer, which I almost always do. The D7 part of this is incorrect. There are ways to accomplish this. I only know the dirty ways, and have them as part of my one-off scripts that I have stashed away. I don't have time to outline how to do this. – mpdonadio Feb 20 '16 at 21:23
  • OK, fair enough. Though I'd still be interested in anybody posting an answer (or comment) to point to some out-of-the-D7-Views-box. AFAIK, there is none. But I'd love to learn from anyone about something that's not ugly, dirty or anything like that. Maybe a somehow related (new?) question could become like "What are those dirty / ugly ways to get this to work in D7 anyhow" ... With a step-by-step answer similar to the "caveat"-part of the other answer here ... – Pierre.Vriens Feb 20 '16 at 21:33

Assume you used Views to build a page display (in Drupal 7). And you want to create a Block display that's exactly the same (same filters, etc). There doesn't seem to be any facility to copy or clone such display.

Actually there is, you can clone it by clicking on +Add, then select Block.

Caveat: When you add a block, page, attachment etc.. it will always clone your original (master) view. (so you can't clone the clone)

Although, if you want to clone the clone, you could export the view, and copy the export code from the other block and modify the machine name. Then you just import the code.

enter image description here

Bonus:

If you then want to make changes to your block, so it's not an identical clone, you then need to select this page override when you click on fields, or other stuff, so it doesn't affect your page or any other view.

enter image description here

  • merci (oeps: thank you) for this answer. Your parg containing "** ... if you want to clone the clone ...**" that you added via the "edit" you applied (about 30 mins ago) is what my question is actually about. Seems like my first "version" of my question wasn't clear enough on that (sorry!), so I refined my question. And because of the "caveat" and the next parg in your question, I seem to understand that you somehow agree with what I wrote in my answer about D7, or am I still missing something? – Pierre.Vriens Feb 20 '16 at 20:45

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.