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"]);
}
}
You can use the Sitecore. Data. Database. GetItem method to retrieve a Sitecore.
You can see the Item ID of any item by looking in the "Quick Info" section of the Content Editor main panel as illustrated...
The string parameter for GetItem()
can be an ID or a Path.
Both will work.
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.
This is expected functionality. You can pass both ID or path to this method, however documentation may not be clear on this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With