Referencing Code File in Sitecore Presentation

I started this a long time ago but never posted it.  Thought I would share it now…

Let me preface this by saying that this was work from an agency partner that did some work for a client I worked for.  The company had decided to do their site in house… and with good reason.  This was a 3rd party agency that created it originally.  This has allowed me some insight into some new practices that I cannot help but say to myself “You didn’t quite think that one through, did you?”.  I’d like to share a one of those things:

  • Sitecore layout type items should NOT… — EVER — point to the same code file.   For example:  (the following are SitecoreSublayout Items created in the Presentation area)
    • Generic Sublayout item  field:  ascx file =   “/layouts/sublayouts/genericSublayout.ascx”
    • Foo  item field:  ascx file =   “/layouts/sublayouts/genericSublayout.ascx”
    • Bar item  field:  ascx file =   “/layouts/sublayouts/genericSublayout.ascx”

While this may seem like a good idea, this makes it absolutely IMPOSSIBLE for you to know the consequences of making changes/updates to the genericSublayout.ascx file since you have no idea what items are using the code.  The only thing I can think of why they did this is to maybe change the data source.. in which case, I can think of many other ways that are better than having multiple Sitecore items point to the same code file.