More in this section

Forums / Developing with Sitefinity / Correct way to override NewsItemsList view?

Correct way to override NewsItemsList view?

5 posts, 1 answered
  1. bemara57
    bemara57 avatar
    135 posts
    Registered:
    27 Mar 2008
    18 Jul 2010
    Link to this post
    I am trying to override the NewsItemsList view and I almost having it, but there are strange results. Here is what I have in my ControlsConfig.xml:

    <viewSettings hostType="Telerik.News.WebControls.Admin.NewsItemsView">
        <views>
            <remove name="NewsItemsList"></remove>
            <add name="NewsItemsList" viewType="Netopia.Sitefinity.News.WebControls.Admin.NewsItemsList, Netopia.Sitefinity.News"></add>
        </views>
    </viewSettings>

    Problem is that when I go to "News Items" link in the News module in the admin, instead of going to the list, it opens a news item view. This is the URL: 

    http://localhost/sitefinity/sitefinity/admin/Modules.aspx?module=News&route=NewsControlPanel.NewsItemsView

    BUT if I go to this URL manually it brings up my custom NewsItemsList correctly:

    http://localhost/sitefinity/sitefinity/admin/Modules.aspx?module=News&route=NewsControlPanel.NewsItemsView.NewsItemsList

    Is there another place I am supposed to override, or missing something else?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    18 Jul 2010
    Link to this post
    Hi bemara57,

    NewsItemsView is a host for NewsItemsList. NewsItemsList is the default view for NewsItemsView. If you access NewsItemsView or NewsItemsList the same template is loaded by default. There should not be a difference.

    I verified the mapping and it works fine on a local project. Check whether the application has been restarted or you are making some navigation in your code.

    Best wishes,
    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
    Answered
  3. bemara57
    bemara57 avatar
    135 posts
    Registered:
    27 Mar 2008
    22 Jul 2010
    Link to this post
    It seems to only happen when you have the NewsItemNew AND NewsItemEdit mapped too. Even if there is no logic in those files (just overriding). I tried this for Events too with same results, so it may be the underlying Generic Content. I also tried this for Standard and Community editions. All the same. Doesn't seem to work correctly when you have new, edit, and list file mapped.
  4. bemara57
    bemara57 avatar
    135 posts
    Registered:
    27 Mar 2008
    22 Jul 2010
    Link to this post
    Below is a temporary workaround that may help the issue:

    public NewsItemEdit()
    {
        //WORKAROUND: WHEN MAPPING TEMPLATES FOR NEW, EDIT, AND LIST THEN DEFAULT VIEW GOES TO EDIT WHEN IT SHOULD GO TO LIST
        if (this.Context.Request.RawUrl.EndsWith("/sitefinity/admin/Modules.aspx?module=News", StringComparison.OrdinalIgnoreCase) || this.Context.Request.RawUrl.EndsWith("/sitefinity/admin/Modules.aspx?module=News&route=NewsControlPanel.NewsItemsView", StringComparison.OrdinalIgnoreCase))
        {
            this.Context.Response.Redirect("~/sitefinity/admin/Modules.aspx?module=News&route=NewsControlPanel.NewsItemsView.NewsItemsList");
        }
    }

    Notice that I had to put this in NewsItemEdit (constructor)... it is not needed in NewsItemNew. I hope this helps.
  5. bemara57
    bemara57 avatar
    135 posts
    Registered:
    27 Mar 2008
    23 Jul 2010
    Link to this post
    I found what my problem was.. the sequence of how you add the mappings matters. I found the documentation for the SetDefaultView and it uses the first added view as the default.

    <viewSettings hostType="Telerik.News.WebControls.Admin.NewsItemsView">
        <views>
            <remove name="NewsItemNew"></remove>
            <remove name="NewsItemEdit"></remove>
            <remove name="NewsItemsList"></remove>
            <add name="NewsItemsList" viewType="Netopia.Sitefinity.News.WebControls.Admin.NewsItemsList, Netopia.Sitefinity.News"></add>
            <add name="NewsItemEdit" viewType="Netopia.Sitefinity.News.WebControls.Admin.NewsItemEdit, Netopia.Sitefinity.News"></add>
            <add name="NewsItemNew" viewType="Netopia.Sitefinity.News.WebControls.Admin.NewsItemNew, Netopia.Sitefinity.News"></add>
        </views>
    </viewSettings>

Register for webinar
5 posts, 1 answered