More in this section

Forums / General Discussions / News ItemTemplate Index

News ItemTemplate Index

2 posts, 0 answered
  1. Paulo
    Paulo avatar
    21 posts
    06 Dec 2010
    21 Jan 2011
    Link to this post

    I am trying to define my own template of the news list and I must know what is the last element to give him a diferent style.
    I have tried to acomplish this using the folowing code
    <telerik:RadListView ID="NewsList" ItemPlaceholderID="ItemsContainer" runat="server" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false">
            <div class="col-second-box-bg">
            <h3 class="bg txt-shadow">News</h3>
            <ul >
                <asp:PlaceHolder ID="ItemsContainer" runat="server" />
                <li  class='<%# ((ListViewDataItem)Container).DisplayIndex  == 1 ? "last" : "" %>'>
                <h5 >
                    <sf:DetailsViewHyperLink ID="DetailsViewHyperLink1" TextDataField="Title" ToolTipDataField="Description" runat="server" />
                </h5>  ...

    And the result is an error when using:
     <%# ((ListViewDataItem)Container).DisplayIndex  == 1 ? "last" : "" %>

    How can I accomplish this without rewrite a new NewsList Widget?

    Thanks in advance.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    21 Jan 2011
    Link to this post
    Hi Paulo,

    The problem here is that our template parser cannot parse the value you use. Sitefinity uses its own parser for parsing embedded resources. Compared to the ASP.NET parser, this parser has limited capabilities for parsing C# code. In one of the future updates it will be added the option of using the ASP.NET template parser for similar scenario like yours.

    The solution requires to remove this code from your .ascx file and then to move it to a custom class that inherits from MasterListView and its InitializeControls method where you will be able to access NewsList from the view container

    To register your custom MasterListView,open App_Data/Sitefinity/Configuration/NewsConfig.config and register the new MasterListView.

            <contentViewControl definitionName="NewsFrontend">
                    <view viewName="NewsFrontendListCustom" ViewType="Telerik.Sitefinity.Samples.Class2, Telerik.Sitefinity.Samples" />

    Finally you have to set the custom MasterListView inside  Home > ControlDefinition > Views > NewsFrontendList of the NewsView control

    All the best,

    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
2 posts, 0 answered