The first question you’re going to ask is.. why the heck would you do that?

  1. Part of me is a little bit of a perfectionist. We’re not quite launched yet, and I want the presentation details as clean as possible before we start.  A good foundation never hurt.
  2. Part of me is still a little queasy when it comes to the four-tier set of presentation details on items.  I’m not alone.
  3. This is likely to be more performant.  Even just a hair when you take into account some higher-traffic sites.  I realize it’s cached, but it has to get processed a first time.

With my nice list of three out of the way, let’s get to it.

Consider this Shared Rendering:

That’s a lot of XML, so apologies for that.

Now take in this Final Rendering on the same item:

All that is doing is swapping out the DataSource. That means that in Final, someone changed the Datasource and that’s it.

How do we fix this, you’re wondering.  I came up with a small chunk of code here, which worked much better than I had predicted.  I think I actually said “Whoa, that’s it??” when it worked.

Yeah, that’s it.  The beauty lies in the “Parse” method. It actually composites all the deltas and gives you a true “final” value that can be set back on the Shared Renderings.

Here’s the final result:

Note that the only line changed is the highlighted one. This really is a surgeon’s approach to merging things back down a level, and I hope this helps someone else out!