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 - Current Revision


Page Revision: Tue, Jul 31, 2012, 1:42 PM


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

Although you can write code to create a Sitecore user without specifying a domain, the Sitecore Admin UI (Security Editor, Access Viewer, etc.) won't work for such a user. You are therefore strongly encouraged to create users within a domain. This effects two areas of your code: the Login page and the User Registration page. See the Sitecore Security Overview page for more details.

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