Monday, October 19, 2015

rootPath and startItem attribute usege in Sites configuration in Sitecore

Recently, one of my colleagues asked me a question which questioned my knowledged in Sites configuration attributes in Sitecore web.config file

Question:

We have a content tree as follows




When a user visits the http://scfootsteps.local/ , user will be presented with the /sitecore/content/home item, which is the combination of rootPath + startItem in the <sites> configuration

<site name="website" rootPath="/sitecore/content" startItem="/home" ... />


But, what happens if user visits http://scfootsteps.local/aboutus url ?

Answer :

Before degging deeper into this, first refresh our minds with definitions of rootPath & startItem attributes in <sites> configuration

rootPath
The path to the root item of the site in terms of Sitecore content tree. For example, it is set to /sitecore/content for the “website” site.

Quote : https://sdn.sitecore.net/SDN5/Articles/Administration/Configuring%20Multiple%20Sites/Adding%20New%20Site/site%20Attribute%20Properties/rootPath.aspx
startItem
The path to the start Item of the site. This Item will be opened by default when the site is requested. All relative URL paths will be relative to the startItem.

Quote : https://sdn.sitecore.net/SDN5/Articles/Administration/Configuring%20Multiple%20Sites/Adding%20New%20Site/site%20Attribute%20Properties/startItem.aspx

So, that means, anything under the "rootPath" is accessible from typing url.


Question :

Then the next question is, what happens if there are two items with the same name as follows
1) /sitecore/content/aboutus
2) /sitecore/content/home/aboutus



Answer :

Answer is, if item with the same name exists in under both nodes, item inside the /home (i.e. startItem) will get priority






When we delete/remove the item inside the home node (i.e. "sitecore/content/home/aboutus"), item outside the /home node (i.e. "sitecore/content/aboutus" will be displayed for the same url (http://scfootsteps.local/aboutus)





In the next post, we will dig deep into code to see how this above mentioned functionality is handled by Sitecore

happy Sitecore Footsptes  :-)

No comments:

Post a Comment