lørdag den 23. august 2014

Automatic Multisite Handling By Traversing Sitecore Tree

Add automatic multisite handling to your Sitecore site by traversing the Sitecore Tree to find the available sites. You can decide to use the site name as subdomain or you can specify a hostName in a Sitecore field on the site-item.


 

 

 

 

Web.config changes

Adding a config section for configuring the multisite handler.

 <configSections>  
      <section name="Netmester.ItemResolver" type="Netmester.ItemResolver.Configuration, Netmester.ItemResolver"/>  
 </configSections>  
 <Netmester.ItemResolver SitecoreWebSiteName="subsites" UrlSyntax="{$}.mydomain.dk|www.{$}.mydomain.dk" HostNameField="hostNames" TargetHostName="targetHostName" />  

  • SitecoreWebSiteName -  The name of the site defined in tag in web.config. Is used as template when the sites are created.
  • UrlSyntax - Specifies the syntax used as hostName for each site created. 
  • HostNameField - Specifies a field on the site-element that should be used as hostName. Pipes can be used.
  • TargetHostName - Specifies a field on the site-element that should be used as targetHostName. If none is specified the first one defined as hostName is used.

Override the standard sitecore siteprovider.

 <siteManager defaultProvider="config">  
      <providers>  
           <clear/>  
           <add name="config" type="Netmester.ItemResolver.SiteProvider, Netmester.ItemResolver" siteList="sites" checkSecurity="false"/>  
      </providers>  
 </siteManager>  

Code

Configuration class

Class associated with the config section defined in web.config

Faste læsere