I am developing an application with Umbraco and VS 2017. For a certain Document Type, there are a lot of variations in just one small part of its content. What I do not want to do is create a lot of distinct documents for every variation. Is it possible, somehow, to have only one Document and change dynamically only a part of it? If yes, how?
Then, how would it be possible to call e.g. @Umbraco.Field("body") with some argument (which should define the desired variation) and get the right every time content?
I have found it great to provide flexibility for a small aspect of a page.
The way to set it up is:
Define document types (without template) for the various variations you have.
In developer section create a new data type using the Nested Content and within that add the document types created above. You can restrict the minimum and maximum items.
Then on the page with the variation add the data type created above.
The "fun" bit is then writing the code to "switch" the output based on the variation used on the page. I separate this into separate partials (which may be overkill) but the benefit is that if you have a new variation in the future it becomes a simple task of updating the datatype, and then creating a new partial.
Hi Nigel,
thank you for your answer. However I do not have Nested Content in Property editor list. I 've found that's a Umbraco 7.7 feature (my version is 7.6). Moreover, with that solution I have to create about 60 documents (the variations' number) and that's painful. I am thinking of creating one document with the common content and add to it programmatically with C#. What are your thoughts?
The classic way would be to create a composition with your common properties in and then have each of your doc type variations inherit this common composition.
But if there are a lot of variations then Nigel's suggestion of using Nested Content for the variations seems the best best. You can install it as a stand-alone package for versions of Umbraco earlier than 7.7.
Different content within the same Document
I am developing an application with Umbraco and VS 2017. For a certain Document Type, there are a lot of variations in just one small part of its content. What I do not want to do is create a lot of distinct documents for every variation. Is it possible, somehow, to have only one Document and change dynamically only a part of it? If yes, how?
Then, how would it be possible to call e.g. @Umbraco.Field("body") with some argument (which should define the desired variation) and get the right every time content?
Hi Ilias
One possible option is to use nested content.
I have found it great to provide flexibility for a small aspect of a page.
The way to set it up is:
Happy to provide more detail if needed...
Cheers, Nigel
Hi Nigel, thank you for your answer. However I do not have Nested Content in Property editor list. I 've found that's a Umbraco 7.7 feature (my version is 7.6). Moreover, with that solution I have to create about 60 documents (the variations' number) and that's painful. I am thinking of creating one document with the common content and add to it programmatically with C#. What are your thoughts?
Without creating your own (rather complex) property editor there isn't a way to dynamically change a single document type on-the-fly.
The classic way would be to create a composition with your common properties in and then have each of your doc type variations inherit this common composition.
But if there are a lot of variations then Nigel's suggestion of using Nested Content for the variations seems the best best. You can install it as a stand-alone package for versions of Umbraco earlier than 7.7.
is working on a reply...