29 Dec 2005
05 Jun 2009
Link to this post
I have need to generate the absolute url to a single item NewsView from the item's associated IContent object. Unfortunately, I am able only to retrieve a limited relative url from the IContent object (via its associated NewsManager), such as "/the_news_item_title" from the CMSContentBase. I've hardcoded the remainder of the absolute url as a workaround. I would like to build this absolute url programmatically.
I've previously noticed that your NewsView ListPageMaster.ascx achieves this end by populating a HyperLink control having an ID of "fullContent1" -- as though the control were databound in the repeater. However, since 'fullContent1' does not exist as a field in the CMSContentBase or the General Content MetaData associated with the News module, you cannot be databinding this control directly, but rather must be using some procedure to build the necessary absolute url and using it to populate the 'fullContent1' HyperLink control. In short, how do you do it?
I have considered that I could iterate over the CMS Pages looking for NewsView controls, and, when found, check to see if the current NewsView 'housed' my selected IContent object, but it doesn't seem to me that this brute force approach is very scalable. I'm hoping that your method is both more scalable and elegant.