
We can create tabs in our Sitecore content items as shown above. A tab can be created for different reasons. One of the simple reasons is to direct business users how to use that content item like adding Datasources from a specific location in content tree or using specific template, applying rules on a field and so on. Lets see how we can create it.
First open Sitecore Core Database and create and item under path “/sitecore/content/Applications/Content Editor/Editors/Items“. The Item should be based on the “/sitecore/templates/Sitecore Client/Content editor/Editor” template. Here our created item name is “About Home”. The most important field is URL field in the created item which is “TabsController\Index” and in controller code(TabsController) we have to apply attribute routing as shown below. Here Index.cshtml is view file associated with the action method.
[System.Web.Mvc.Route("sitecore/shell/Applications/TabsController/Index")]
public ActionResult Index()
{
return PartialView("~/Views/Tabs/Index.cshtml");
}
To call this route from the Sitecore content Item we need to patch our Sitecore pipeline with below class.
public class CustomMVCRoutes
{
public void Process(PipelineArgs args)
{
RouteTable.Routes.MapMvcAttributeRoutes();
Log.Info("Sitecore is starting........test", this);
}
}
We need to add the patch file in our Include folder to invoke CustomMVCRoutes at particular execution step.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<initialize>
<processor type="MyCMSSoln.CustomMVCRoutes,MyCMSSoln" patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeControllerFactory, Sitecore.Mvc']" />
</initialize>
</pipelines>
</sitecore>
</configuration>
At last go the item in master Database where you want to apply the tab and go in Appearance section Editors field and apply the newly created tab that is About Home(created in core database).
Once you compile and deploy the code and dll and view is updated, newly created About Home Tab will be shown in the content tree.