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, Jun 08, 2012, 9:10 AM


Creating and Querying Items

General

  • 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 Sitecore.Context.Database

  • 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.

Absolute vs. Relative Paths

  • 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 within the Sitecore hierarchy without breaking the code.

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

  • When specifying a Source for a template field (for example a Droplink field), specify a source of the form query://*[@@id='{folderGuid}']/* where folderGuid is the GUID of the folder containing the items for the dropdown list.

Security

User Domains

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