1

I created a view with several displays. The view type is CONTENT.

But now I need to change the type from CONTENT to CONTENT REVISION, without to be constrained to rewrite all the displays.

Is it possible?current view type

  • There is no "Content review" view type - I guess you meant "Content revisions" instead? – marcvangend Apr 30 '17 at 19:50
  • Yes, sorry I will correct my post – Tormy Van Cool May 1 '17 at 8:20
2

Technically speaking, the type of a view corresponds to the base table against which a database query is executed. This means that it sets the stage, so to speak, for the data that is going to be collected. All fields, filters, sort options etc. are configured in relation to that starting point.

Since changing the view type would mean changing the base table, you would be replacing the foundation your view is built on. This a tricky thing to do, because the data you are collecting may not relate to the new base table as it did to the old base table. (In a more radical example, imagine turning a Content view, which retrieves the node ID, into a User view. That would break because users do not have a node ID.)

So is it completely impossible? Maybe not, especially because node and node revisions are somewhat similar. When you look at the exported configuration (YAML markup) of a "Content" view, you will see a line base_table: node_field_data. In a "Content revisions" view you will find the line base_table: node_field_revision. If I had to try this (disclaimer: I never did!), I would do the following:

  1. Duplicate the view I want to change (so I don't lose the original) and save it without changing anything
  2. Go to /admin/config/development/configuration/single/export to get the config YAML of the duplicated view
  3. Copy the config and paste it into a text editor
  4. Change base_table: node_field_data to base_table: node_field_revision
  5. Delete the duplicated view
  6. Copy the edited YAML from your text editor and import it via /admin/config/development/configuration/single/import
  7. Hope that the import doesn't generate errors
  8. Go to the configuration screen of your newly imported view, see if it reports problems, and try to make it work

Good luck. When you do try the above, I would love to read if it worked for you.

  • 1
    it worked without errors. But I had to recheck the fields, 'cause it has lost some of them in a couple of displays. However, it's better so than to have to rewrite the whole view. – Tormy Van Cool May 1 '17 at 8:37
  • Thanks for the feedback. That's exactly the kind of problems I expected to occur. I'm glad that they were fixable and that this approach still saved you time. – marcvangend May 1 '17 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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