Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Page History: Best Practices and Pitfalls to Avoid - Sitecore

Compare Page Revisions



« Older Revision - Back to Page History - Newer Revision »


Page Revision: Fri, Apr 13, 2012, 10:08 AM


Creating and Querying Items

  • Items should NEVER be created directly in the WEB database. This is because when the MASTER database is published to WEB, any item not in MASTER will be deleted, and these deleted items cannot be recovered.

  • Public content should be queried from WEB

  • User-specific content (e.g., orders) should be created in and queried from MASTER. "User-specific content" means any content created by the end users of the website.

  • Although the simplest way to query items is to use the absolute path, as in the following example, this is not recommended.

var items = Sitecore.Context.Database.SelectItems("/sitecore/content/MyStore/Orders/*");

It is instead better to query that folder by its ID, then query its contents via a relative query. This way, the content can be rearranged withing the Sitecore hierarchy without breaking the code.

var folder = Sitecore.Context.Database.GetItem(new Sitecore.Data.ID(folderGuid));
var items = folder.Axes.SelectItems("*");

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.