This project is read-only.

How to get ContentItem from ItemSelector (UrlSelector) property

Oct 18, 2007 at 11:08 AM
what is the best practice to get instance of content item if I have its ItemSelector value?

I have some Item with property of type ItemSelector and for example, value of that property is /somePath/SomeItem.aspx .

I want to make instance of type ContentItem with value (/somePath/SomeItem.aspx) of ItemSelector.

Oct 18, 2007 at 2:39 PM
I make it with N2.Factory.UrlParser.Parse("/somePath/SomeItem.aspx") and not sure that is the best practice?

Oct 18, 2007 at 3:07 PM
When you have the url to an item that works nicely.

You can also store a reference to another item like this:
		[EditableLink("Current sprint", 110)]
		public virtual ScrumSprint CurrentSprint
			get { return (ScrumSprint)GetDetail("CurrentSprint"); }
			set { SetDetail("CurrentSprint", value); }

The difference being that the page is referenced by the item's id by the CMS (and thus isn't affected if the url changes). That ScrumSprint is a content item class.