Changing renderings from rendering parameters to datasource

Recently, for one of our projects, we found that a large number of the client’s renderings were using rendering parameters unnecessarily. In order to allow for personalisation and a better Experience Editor experience, we recommended to the client that they change these renderings to use datasources instead.

The process (which may vary slightly for your instance) went something like this:
For each rendering to be converted:-

  1. Move the related rendering parameters template from its current folder (which in this case was a folder dedicated to rendering parameters) to a more appropriate folder for data item templates.
  2. Make sure that all sub-items are serialised when the template has been moved – I encountered what seems to be a bug with Unicorn, where it doesn’t serialise them. If you get this, you might need to reserialise, or save each sub-item manually.
  3. If the template currently has a name specific to rendering parameters, rename it to something more appropriate.
  4. If required, make sure that the _Standard Values are set.
  5. Where the rest of your site data lives, create a new folder which will be used to store items of the template in question. Set the insert options to add this template.
  6. Change the rendering’s datasource location to be the newly created folder.
  7. Change the rendering to have no rendering parameters template, and instead use a datasource template of the recently moved template.
  8. Remove the “Standard Rendering Parameters” template from the base templates of the new datasource template.
  9. Add a new item to Core DB with the path something like: /content/Applications/WebEdit/Edit Frame Buttons/Signup Form Button/Signup Form
  10. Set Fields for this new item to be a pipe-delimited list of fields that the content editors will need to edit (generally all of them).
  11. In the Visual Studio solution, move the rendering parameters model into the folder where the data items models live, and rename the file and class name if required.
  12. Change the namespace to match the new location.
  13. Inside the controller method (assuming the rendering is a Controller rendering), remove all code that uses the rendering parameters, and instead, set the datasource to be the RenderingContext.Current.Rendering.DataSource.
  14. Change the view using this rendering:
  15. Add a check for if (Model != null), and display a message if in experience editor mode.
  16. Add “using (BeginEditFrame…” and use the path of the folder for the webedit button you added earlier.
  17. Added a check for Sitecore.Foundation.SitecoreExtensions.Extensions.ItemExtensions.IsDerived using a configuration item for the template ID. Display a message if wrong template and skip the rest of the view.
  18. Changed all references to items in the Model be use @Editable(x => x.)

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: