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

Forums / Developing with Sitefinity / Modifying NewsView template

Modifying NewsView template

11 posts, 0 answered
  1. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    24 Jun 2009
    Link to this post
    Hi, I was wondering what the default ControlTemplate is for NewsView. I want to customize it, but I cannot find the file to change to do so. Currently, I have 'ContentViewItemList.ascx' specified. I cannot get the author to show up, though. I looked at the source code and some other pages to try to figure it out but I have had no luck thus far.

    Here is the current code I have in place. The only change I have made so far to the author section is I added the text property to the author literal control:

    <class="sf_postAuthor"
        <asp:Literal runat="server" Text="<%$Resources:Author %>"></asp:Literal> 
        <asp:HyperLink ID="postedBy" runat="server"
            <asp:Literal ID="Author" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Author")%>'></asp:Literal> 
        </asp:HyperLink> 
    </p> 

    Any help would be greatly appreciated!

    Cheers,
    anders
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    24 Jun 2009
    Link to this post
    Hi andersleet,

    If you are using Sitefinity 3.6 all templates for the ContentView based controls are embedded. Please take a look at the following article How to map a view

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    25 Jun 2009
    Link to this post
    Thanks Ivan. Should I be changing the layoutTemplatePath at all? My gut tells me to remove the /admin/ part of the path since I am not concerned with the admin area at the moment, only the 'live' version.

    Thanks for your help,
    anders
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    25 Jun 2009
    Link to this post
    Hello andersleet,

    You are correct. The templates for the public views of controls are located in ~/Sitefinity/ControlTemplates, as opposed to ~/Sitefinity/Admin/ControlTemplates for the administrative view of controls.
     
    Greetings,
    Rado
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    25 Jun 2009
    Link to this post
    Thanks Rado, I am glad I am thinking along right lines. I cannot get this to work yet, however. This is how my newly created configuration XML looks:

    <?xml version="1.0" encoding="utf-8" ?> 
    <controlsConfig> 
        <viewMap> 
            <viewSettings hostType="Telerik.News.WebControls.NewsView"
                <additionalTemplates> 
                    <!--Provides user interface for displaying a list of news items in the NewsView control for the News module.--> 
                    <add key="ItemListTemplatePath" layoutTemplatePath="~/Sitefinity/ControlTemplates/News/ListPageMaster.ascx" /> 
                    <!--Provides user interface for displaying a single news item in the NewsView control of the News module.--> 
                    <add key="SingleItemTemplatePath" layoutTemplatePath="~/Sitefinity/ControlTemplates/News/ListPageDetails.ascx" /> 
                </additionalTemplates> 
            </viewSettings> 
        </viewMap> 
    </controlsConfig> 
     

    I copied the ListPageMaster/ListPageDetails.ascx over to the appropriate folders and changed the way the date is to be displayed (or so I think):

    <class="sf_newsDate"
        <asp:Literal ID="Publication_Date" runat="server" Text="{0:MMMM dd, yyyy}" /> 
    </p> 

    Originally the text property had a value of "{0}", usually the date/time controls have a pattern (throughout SF I have noticed it is predominately "D"). I saw another post somewhere where they used a similar format as I did above for the value of the text property.

    The template has not changed, though. I did remove the declaration of where the template should be loaded from the edit menu of my NewsView control. I also restarted my webserver ( I have to do this anytime I make any change to a file? rather annoying lol ), so I am unsure of what step I need to take next to get this template to be applied. The article Ivan linked infers that it should happen automagically :P

    Cheers,
    anders
  6. andersleet
    andersleet avatar
    155 posts
    Registered:
    03 Jun 2009
    25 Jun 2009
    Link to this post
    I forgot to mention that I also copied the resource files into the App_LocalResources folder, per the article.
  7. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    25 Jun 2009
    Link to this post
    if i'm not mistaken, I don't believe the template format strings currently work this way, but instead all text in the controls are overwritten with the default format. please correct me if I'm wrong because I've been needing to do this for some time as well!

    However you can change this at the page level in stiefinity by editing the NewsView control. there is a Settings link on the right side of the Basic Tab. under Date there is a link to change the format string using a drop down menu, where you can choose the format string

    If none of these format strings match what you're looking for, you can set a custom string.. In the advanced tab under appearance there is a text box for DatesFormat where you can enter your custom format string. enter it without the braces, for your example simply enter MMMM dd, yyyy.

    I hope this was helpful!
  8. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    25 Jun 2009
    Link to this post
    Hello SelArom,

    You are correct. The date settings used in the view template are overwritten by the default ones. Your way of doing this correct. Please note however that if you are using page caching the changes in formatting might not be visible right away, you will have to clear the cache first.

    There is also a way to add your custom date format to appear in the settings view. Please take a look at: Working with ContentView designer (part 5): Implementing custom designer setting.

    Andersleet, a faster way to restart your website will be to just "modify" your web.config file, just add a couple of white spaces, delete them, and then just save the file. This will restart the website without restarting the web server (still is annoying).



    All the best,
    Rado
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. jkregala
    jkregala avatar
    159 posts
    Registered:
    22 Sep 2009
    16 Oct 2009
    Link to this post
    This is making me crazy already. All I want to do is to MOVE THE THUMBNAIL PHOTO located within NewsView Control to the top of the said control. That means, the rest of the Control elements including the NewsTitle, NewsDate, ReadMore and so on will fall under it. I tried to actually "follow" what's been said here step by step but it's getting me insane already as what I do doesn't work!

    All I could ever hope right now is that Sitefinity came with a GUI editor of the Controls' interface.

    What can I do? Thanks.
  10. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    16 Oct 2009
    Link to this post
    Hi Jan Kenneth Regala,

    Thank you for using our services.

    Can you please elaborate more specifically on what steps you are actually taking to achieve this, as well as the exact version of Sitefinity that you are using. I have edited the ~/Sitefinity/ControlTemplates/News/ListPageMaster.ascx file so that thumbnail control appears before other controls:
    <asp:Repeater ID="repeater" runat="server">
        <HeaderTemplate>
            <ul class="sf_newsList">
        </HeaderTemplate>
        <ItemTemplate>
            <li>
                <asp:PlaceHolder ID="ThumbnailHolder" runat="server">
                    <p class="sf_newsThumbnail"><asp:Image ID="Thumbnail" runat="server" /></p>
                </asp:PlaceHolder>
                <h2 class="sf_newsTitle">
                    <asp:HyperLink ID="fullContent1" runat="server">
                        <asp:Literal ID="Title" runat="server"></asp:Literal>
                    </asp:HyperLink>
                </h2>
                <p class="sf_newsDate">
                    <asp:Literal ID="Publication_Date" runat="server" Text="{0}" />
                </p>
                <p>

    Then I have set the News View controls to use the external template for the items list mode in the controls config file:
    <viewSettings hostType="Telerik.News.WebControls.NewsView">
        <additionalTemplates>
          <!--Provides user interface for displaying a list of news items in the NewsView control for the News module.-->
          <add key="ItemListTemplatePath" layoutTemplatePath="~/Sitefinity/ControlTemplates/News/ListPageMaster.ascx" />
        </additionalTemplates>
      </viewSettings>

    Lastly I have restarted my web site so that the changes can take effect. You can see the result in the attached image.

    All the best,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  11. jkregala
    jkregala avatar
    159 posts
    Registered:
    22 Sep 2009
    20 Oct 2009
    Link to this post
    Thanks Mr. Radoslav Georgiev! That is what I was looking for! :)
Register for webinar
11 posts, 0 answered