Working on a client's site and they have thousands of items with layout. In the layout of every page we have two renderings - Top Navigation, then Pinned Navigation. We made an architectural mistake early on by putting Top Navigation before Pinned Navigation. We need Pinned to be before Top. Usually, this would be pretty easy to fix, but there's a bit of background here.
As explained in a recent question I posted, the navigation renderings are set on a base page template, and there are other templates with custom shared layouts that inherit from Base Page. The reason why this can't be fixed easily? For some reason when I change the Base Page template, changes do not automatically carry forward to other page templates that inherit from it... and resetting standard values isn't an option as we set a custom shared layout on those templates standard values (I'm pretty sure resetting would break all pages that use that template, if not immediately, the next time someone resets layout on the page level).
So, I thought maybe a PowerShell script would be the answer, but the only way I can think of (updating the
__Renderings field manually) didn't work. I literally reordered the XML in the field using Raw values, saved, and the reorder did not happen (when I open Presentation Details again).
Then I found another way, through Sitecore Search, if I enter a query and click Search Operations -> Apply presentation, I could theoretically apply the reordering of these two renderings to all pages, but every time I do that I get an error (even if the results I am trying to apply presentation to are all of the same template type):
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Exception: Can't start with unequal nodes at Sitecore.Xml.Patch.XmlDiffHelper.DoCompare(IXmlElement original, IXmlElement modified, IElementIdentification identification, IComparisonContext context) at Sitecore.Xml.Patch.XmlDiffHelper.Compare(XmlDocument original, XmlDocument modified, IElementIdentification id, XmlPatchNamespaces ns)
So I've literally run out of options and am looking for some way to do this. I suppose not using renderings for header navigation components (and just having
Html.Partials in the layout file) might have been a better option from the beginning, but I really don't know.
P.S.: Just as I was about to submit this question, one possibility hit me (although it's a workaround): using a different placeholder for one and updating the placeholder references in the layout cshtml. However, I feel like it would be nice to actually know a real solution to this. So, the questions I would like answered are:
- Why does updating the Base Page template not update other page templates inheriting from it automatically? (I am updating SHARED layout only. I NEVER update final layout)
- Why does updating the
__Renderingsfield through Raw values and saving not have any impact on the ordering of the renderings when opening Presentation Details?
- Why am I getting an error trying to apply presentation to multiple page items of the same template type and what does the error mean (researched the main error message, nothing found).