Sitecore and ASP.Net - my experience

- by Christian Kay Linkhusen

NAVIGATION - SEARCH

Overriding of the Sitecore.Context.Item

In a solution I'm working on, we have a newslist presentation where News are created in Sitecore as Items in different parts of the content tree, and they are all shown on the same list. When you follow a link on the list, the Newsitem is shown in the context of the list and not from the address reflecting where the Item is created in Sitecore.

Address of NewsItems that are presented in the context of the newslist would be on the form:
www.host.net/list/item?id={guid}

 
When you implement your webcontrols for presentation of the Item, it is not possible to reference Sitecore.Context.Item because the context will be the containeritem used as an "Presentation container Item" and not the newsitem you want to show. A solution could be to create a local variable "currentItem" where you get the item you want to render by caling something like Sitecore.Context.Database.GetItem(Request.QueryString["id"]); in the Page_Load() or similar. But this solution, will not work if you have Items with different layouts, eg. if you are using Web Forms For Marketiers and have created a webform for one of the Items you are trying to render in the context of the list.

A solution for the problem could be to override the Context Item by creating a httpRequestBegin processor and execute right after Sitecores Itemresolver.
More...