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(); } } }

4 comments:

Anonymous said...

Excellent article, Alexander! Although the proxy items are a wonderfull solution, we don't use them a lot. Might be to complex for some editors...

Anonymous said...

A nice article Alex,

Good job. I really think we should consider making this one into a Sitecore article on the developer network. Could you please inform the documentation team?

I havent tried to create proxy items dynamically. Even old dogs can learn new tricks :-)

Anonymous said...

BTW. You should claim your blog at Technokrati

http://www.technorati.com/signup/

Unknown said...

Blog posting was edited - a link to SDN5 documentation was added.