Monday, July 18, 2016

Purpose of Area field on Sitecore 8.1?

So, It all started with an un-answered question on sitecore community on why the 'Area' field does not seem to work on View Rendering.
https://community.sitecore.net/developers/f/8/t/3509

Field In Question





Human tendency is if we are taking pain to enter a value for a field on sitecore, it does do something dynamically.  The first thought is, if I fill in the Area field on Sitecore Rendering Item, It should auto pick the path to my *.cshtml by constructing it rather than depending on us to fill in full path of the view in the Path field.

But, if I tried that it caused error on my end that it can not find the view.
I started reading around to see what is the purpose of this Area field? May be the purpose is bigger/better? I mean sitecore added this in the latest release.

Good Reads Below -
http://www.nonlinearcreations.com/Digital/how-we-think/articles/2015/10/Sitecore-8-1-MVC-Improvements-Area-Support-and-MVC-5-2-3.aspx
https://ctor.io/new-in-sitecore-8-1-mvc-areas/
https://citizensitecore.com/2015/10/26/mvc-areas-in-sitecore-8-1-a-step-by-step-guide/

Based on the blogs, this new token or field value could be used for view resolutions inside your controller or view renderings, but, sitecore would still need full path in the path field.

So, the gist is you read this field as you read any other field on the code.  Only note is if you need to use this field value on code use it by name and not GUID(As it is unique obviously for each rendering).

Something like..Sitecore.Context.Site.Properties["area"];

If you have your own Area Resolving strategy, which by the way you need to plugin properly for it to work, then in your class use the Area value when needed.

Got it! Some purposes that could pay off on adding this new field.  I am still curious to know the ground breaking reason if any that Sitecore added this field.

Anyone???







No comments :

Post a Comment