API techniques – accessing items in the sitecore tree

Sitecore offers various methods for accessing items in the sitecore tree. The following shows some examples:

Typically we will store key item guids and key template guids in static classes so they can be used throughout the code.

From experience it is rare to use path to access items since an items path can change over time – essentially it is content rather than something fixed. An items guid should never change even when it is packaged up and distributed to multiple environments.

Its worth noting that once you have accessed an item, it may be it is null. Another scenario is that it doesnt have any versions – this can be caused by an item being published when it isnt in a final workflow state.
These are easy things to check:

Leave a Reply

Your email address will not be published. Required fields are marked *