3

Using Sitecore 8.2 Update 3 with the hot fix for the item/branch/template publishing issue.

We are working on functionality for our client where when certain items are moved, the item:moving event is triggered and the template of the item could be changed to another similar template, used for differentiating item categories.

When looking at one of the renderings in this item, pre-move the rendering has parameters that were set to be different from its standard values (for example, an Amount to Show parameter has a value of 6, while the standard value is 5). After the move and template change, the UI shows that all of the rendering parameters have reverted to their standard values. However, if I look in the raw values of the item and scroll down to the Layout section, in the rendering XML string I can see the rendering parameters set correctly. It also appears the incorrect parameters are being read through to the display code as well, as only 5 items show in the designated rendering, but I see the parameter string in raw values in the web database as well.

I would like to find a fix that doesn't involve the client needing to manually reset parameters that, honestly, look like they're still there in one aspect of Sitecore's data handling.

EDIT: The code I'm using to implement the change is this (where item and MasterDb have been established):

TemplateItem newTemplate = MasterDb.GetTemplate([templateId]);
item.ChangeTemplate(newTemplate);

EDIT 2: Interestingly, if I change the template through the content editor back to the original template it started as, the rendering parameters reappear as they should. As far as I know, there's nothing in the rendering parameters that should tie it to template necessarily, especially if I can see the correct raw values.

EDIT 3: I heard back from Sitecore support...no solution as yet, but I confirmed the same behavior happens if I'm in the content editor and use the Change Template functionality in the ribbon.

1

It turned out to be a matter of layout deltas. The two templates in question had the same rendering, but the "uid" field in the raw values was different between the two. I wrote something to flip them as well, and the values mapped correctly.

However, I'd note this was a legacy project we took over and upgraded, and from an architecture standpoint, I'd recommend different approaches to the problem if designing from scratch. Either putting the renderings on a common base template (so the "uid" field should be the same) or, better still, doing the operation to not rely on needing to change the template to make the content flow properly.

| improve this answer | |

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.