7
votes

I am on Sitecore 6.5.

The below code is working fine but I don't understand how. The GetItem() method has six overload functions where it takes string values as just item paths.

In this case it's taking in an id as a string and correctly returning the item (the location is Sitecore droplink field). Am I missing something?

private Sitecore.Data.Items.Item LocationItem
{
    get
    {
        return Sitecore.Context.Database.GetItem(Item["Location"]);
    }
}
3

3 Answers

15
votes

The string parameter for GetItem() can be an ID or a Path.
Both will work.

3
votes

Sitecore can take a path or an ID as the string. Item["Location"] will contain a GUID (as the field type is a droplink), which you're currently retrieving as a string.

3
votes

This is expected functionality. You can pass both ID or path to this method, however documentation may not be clear on this.