1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Determine if NewsView is in Master or details mode from seperate control

Determine if NewsView is in Master or details mode from seperate control

4 posts, 0 answered
  1. Drew Greenwell
    Drew Greenwell avatar
    66 posts
    Registered:
    11 Feb 2010
    18 Mar 2010
    Link to this post
    Is there an established way to determine if you are viewing a page with a NewsView that is in Master or Details mode from a seperate control. I know that i can do this with a regular expression against the url, but Id rather wire it up.

    I basically only want bind or display the control if the page is in SingleItemView(aka Details)


    Thanks in advance for any insight or direction

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    18 Mar 2010
    Link to this post
    Hello Drew Greenwell,

    You could add the following code in ListPageDetails template

    Telerik.Cms.Engine.ContentManager Manager = new Telerik.Cms.Engine.ContentManager("News");
    Guid id = (Guid)((Telerik.Web.IUrlRewriteData)Context.Items[Manager.Provider.ContentItemKey]).Data;


    If the id is empty then there is no item in details mode. If the other control is on the same page you could create a custom class that inherits from NewsView, override CreateSingleContent() and there hide your control. CreateSingleContent() is called when you want to see an item in details mode.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Drew Greenwell
    Drew Greenwell avatar
    66 posts
    Registered:
    11 Feb 2010
    18 Mar 2010
    Link to this post
    Ivan thanks for your help so far,
    I have inherited from NewsView and I can avoid showing the control by overriding CreateContentList and CreateSingleContent. However the control behavior is being a little sparatic  and Im not really sure if im moving in the right direction

    the idea is this i have 2 columns (each is a content placeholder)

    user is greeted with a NewsView in left column and a empty NewsView in right column(base.CreateContentList not called)

    user chooses a news item and the single item is displayed on left, At that point, a NewsView on the right column should display in List mode with the items from that category. selecting an item on the right should should display it on the left. 
    At any point the user should be able to choose a category from the categories list and be able to view the first article in that category on the left, and all articles in the category on the right.

    Does this scenario sound possible inside of sitefinity or will i need to make a custom aspx page so the controls can cross communicate?  The problem now is that if a user selects an article on the left the article list on the right only displays that article in the list and not the full list for the category

    Thanks again for your help
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    19 Mar 2010
    Link to this post
    Hello Drew Greenwell,

    Using the code from the previous post you can get the id of the currently selected item. Once you have the IContent object, you can call GetMetaData method and get the category that is associated with this item. Then you can filter the second control by category using ContentFilterBuilder class. You can perform the filtering inside CreateChildControls method

    sample code

    ContentFilterBuilder filterBuilder = new ContentFilterBuilder(this);
    // we assume that you have the content item
    string categoryName = (string)cntItem.GetMetaData("Category");
    filterBuilder.AddFilter(new ContentFilterStatement("Category", categoryName,
                                                                           ContentFilter.Condition.In,
                                                                               ContentFilter.JoinType.And));

    note that you should change the value of ContentItemKey property for the second control - that will be filtered by categories, otherwise it will read the ContentItemKey from the QueryString and your filtering will not apply. You can change the value of this property form the ControlDesigner >> Advanced  tab >> QueryString keys.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
4 posts, 0 answered