Look for cyclical inheritance among Sitecore templates

I have not blogged for a long time. I am not sure about the reason for that, I cannot say there was nothing interesting in my Sitecore practice, probably I am just too lazy for that.

However I have recently moved to Germany and because of speaking German I am starting to forget English or even worse - I am starting to speak Denglish. So, need more practice. Why not to couple that stuff with sharing some info?

In some Sitecore projects that are actively using template inheritance and have reach templates structure, having cyclical inheritance is very possible. Cyclical inheritance of templates is pure evil. It might cause unexpected behavior of the system.
So I had a task to prove whether there are no such stuff in Sitecore solution. I have made a piece of code that checks for this.

Here it is:

That looks complex, not readable and uses recursion (sorry for that, that was done quickly and no refactoring is planned :) ).
The first method is called by AJAX and returns list of pairs (template path, explanation string). In my web page it looks like this then:


If you have better idea how to get the list of cyclically inherited templates templates in Sitecore, I would love to hear that.

Comments

  1. Where is the implementation of GetMasterTemplates() method.

    ReplyDelete

Post a Comment