Tuesday, 10 September 2013

Getting Sitecore items

All items ca be accessed from Sitecore.Data.Items.Item class.

//Get the master database through a Factory
Database masterDb = Sitecore.Configuration.Factory.GetDatabase("master");



//Retrieving an item with a path through the database
Sitecore.Data.Items.Item myItem = masterDb.Items["/sitecore/content/home"];


//Retrieving an item from an item id
Sitecore.Data.Items.Item mySecondItem = masterDb.Items[new ID("{CC07A18cA-670D-5458-9A1S-G3072D1A0BE5}")];

No comments:

Post a Comment