Monday, January 08, 2007

Proxy Items in 5.3

Here are some details on how the proxy items work in 5.3. Some sample code on how to create a proxy item: public void CreateProxyItem(string name) { Sitecore.Data.Database masterDB = Sitecore.Configuration.Factory.GetDatabase("master"); // getting a proxy template from the template repository Sitecore.Data.Items.TemplateItem proxyTemplate = masterDB.Templates[Sitecore.TemplateIDs.Proxy]; using (new Sitecore.SecurityModel.SecurityDisabler()) { // getting referece to the proxy container item Sitecore.Data.Items.Item proxyContainerItem = masterDB.Items["/sitecore/system/proxies/"]; if (proxyContainerItem != null && proxyTemplate != null) { Sitecore.Data.Items.Item proxyItem = proxyContainerItem.Add(name, proxyTemplate); proxyItem.Editing.BeginEdit(); proxyItem.Fields[Sitecore.FieldIDs.ProxySourceItem].Value = "{F5726884-BDBE-4DDD-9EBE-BB166E68E1EF}"; proxyItem.Fields[Sitecore.FieldIDs.ProxyTargetItem].Value = "{C3F3DBA9-87B3-4EB3-84CF-D75BD7FED626}"; proxyItem.Editing.EndEdit(); } } }

Tuesday, January 02, 2007

Cannot see the template folder?

This is applied to Sitecore 5.3 061102. If you create a folder (template container) for your custom templates in the Template Manager, you might not see this folder in the dialog when adding an item from a template or changing the template. The solution is to edit the \sitecore\shell\Controls\Data\TemplateDataContext.xml file to include the GUID of the template "Template Folder" that is placed under /sitecore/templates/system/templates/. The Filter attribute of the DataContext definition should be edited:
before: Filter="Contains('{E3E2D58C-DF95-4230-ADC9-279924CECE84}, {...}, {...}', @@templateid)"
after: Filter="Contains('{0437FEE2-44C9-46A6-ABE9-28858D9FEE8C},{...}, {...}', @@templateid)"
where {0437FEE2-44C9-46A6-ABE9-28858D9FEE8C} is the GUID of the "Template Folder" template.