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

Forums / Developing with Sitefinity / NewsView Control: Single Article on a Page

NewsView Control: Single Article on a Page

7 posts, 0 answered
  1. Jeff
    Jeff avatar
    124 posts
    Registered:
    05 Aug 2007
    07 Feb 2009
    Link to this post
    If this is documented anywhere, just send me the link and don't bother explaining.

    I've created a news article and wish to add a NewsView control to a page and display the article.

    Simple enough, right? It was under 3.2.

    I don't see an obvious way to select the article from the NewsView dialog (Basic or Advanced mode).

    Am I just on the wrong track here? I must be missing something obvious.

    The new controls are not documented in the User's Guide and are scarcely mentioned in the Developer's manual.

    Please help! I feel like I'm moving backwards in my migration to Sitefinity.

    Thanks,
    Jeff
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    09 Feb 2009
    Link to this post
    Hi Jeff,

    Thank you for using our services.

    There is not NewsView control in Sitefinity 3.2 Standard edition( 3.2.1500.2). Probably, you are using one of services packs. You can limit the articles on the page using Divide the list on pages if there are too many items option under NewsView control settings. There you could set how many items you want to display -1, 2, 3. You can also use FilterExpression property(AdvancedTab >> Filters) and set filter as the below one, which will display only certain News item. I am not sure which version you use, but this culd be set programatilcally as well by overriding the control.

    Publication_Date <= "#now" AND Expiration_Date > "#now" AND Title = "MyNews"  

    Let us know if there is anything else that we can do for you.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Jeff
    Jeff avatar
    124 posts
    Registered:
    05 Aug 2007
    09 Feb 2009
    Link to this post
    Hi Ivan,

    Thanks for the tip. We're getting closer.

    I'm looking to emulate the SingleNews control that was available in 3.2.

    I completely uninstalled 3.2 and started from scratch with 3.5, where the NewsView control is the closest thing to the now obsolete SingleNews.

    By changing the filter, I was indeed able to show only the article I'm interested in. However, I still don't get the content of the article. Just a link to the full story.

    Maybe the paradigm has changed for 3.5 and I shouldn't expect a 1:1 relationship between page and article. If so, please fill me in.

    I do love the rapid pace of new improvments to Sitefinity. I just wish your documentation team could keep up. :)

    Thanks,
    Jeff
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    10 Feb 2009
    Link to this post
    Hello Jeff,

    If you want to show the content you could edit ~\Sitefinity\ControlTemplates\News\Modes\ListPageMaster.ascx template and add literal control that will display the content of your news item.

    <h2 class="sf_newsTitle"
                    <asp:HyperLink ID="fullContent1" runat="server"
                        <asp:Literal ID="Title" runat="server"></asp:Literal> 
                    </asp:HyperLink> 
                </h2> 
                <class="sf_newsDate"
                    <asp:Literal ID="Publication_Date" runat="server" Text="{0}" /> 
                </p> 
                 <p> 
                    <asp:Literal ID="content" runat="server"></asp:Literal> 
                </p> 
                <p> 
                    <asp:Literal ID="Summary" runat="server" Text=""></asp:Literal> 
                </p> 

    Another option is using the Summary, because you will be able to control whether the summary will be shown or not through NewsViewControlDesigner.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Jeff
    Jeff avatar
    124 posts
    Registered:
    05 Aug 2007
    10 Feb 2009
    Link to this post
    That did the trick. Thank you much.

    This is one more example of just how flexible and customizable Sitefinity is. I really like this platform.

    And thank you Ivan for being a living, breathing developer's manual. You make up for the woefully incomplete documentation available for Sitefinity.
  6. Nitesh Rastogi
    Nitesh Rastogi avatar
    15 posts
    Registered:
    24 Aug 2009
    02 Sep 2009
    Link to this post
    Hi

    I am using the news user control provided by the jet30 application.This control displays the news titles in a list form.The code for the same is pasted below.

    protected

     

    void Page_Load(object sender, EventArgs e)

     

    {

     

    ContentManager cm = new ContentManager("News");

     

     

    IList RecentlyUpdated = cm.GetContent(0, numberofitems, "Publication_Date DESC");

     

     

    IList<LinkInfo> WhatsNewLinks = new List<LinkInfo>();

     

     

    foreach (CmsContentBase article in RecentlyUpdated)

     

    {

     

    LinkInfo linkinfo = new LinkInfo();

     

    linkinfo.Title = article.GetMetaData(

    "Title").ToString();

     

    linkinfo.Url = article.Url;

    WhatsNewLinks.Add(linkinfo);

    }

    NewsRepeater.DataSource = WhatsNewLinks;

    NewsRepeater.DataBind();

    }

     

    private int numberofitems = 1;

     

     

     

    public int NumberOfItems

     

    {

     

    get

     

    {

     

    return numberofitems;

     

    }

     

    set

     

    {

    numberofitems =

    value;

     

    }

    }

     

    protected void NewsRepeater_OnItemDataBound(Object sender, RepeaterItemEventArgs e)

     

    {

     

    if (e.Item.ItemType == ListItemType.Item ||

     

    e.Item.ItemType ==

    ListItemType.AlternatingItem)

     

    {

     

    HtmlAnchor itemLink = (HtmlAnchor)e.Item.FindControl("Link");

     

     

    LinkInfo linkinfo = (LinkInfo)e.Item.DataItem;

     

    itemLink.HRef =

    "~/news/" + linkinfo.Url;

     

    itemLink.InnerText = linkinfo.Title;

    }

    }

     

    protected class LinkInfo

     

    {

     

    public string Url;

     

     

    public string Title;

     

    }


    Now my requirement is that when the user clicks on one of the titles displayed the full news content gets opened on another new page.Can you suggest the code changes need to be done and steps for the same.

    Thanks

  7. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    02 Sep 2009
    Link to this post
    Hello Nitesh Rastogi,

    Thank you for using our services.

    Replies have been sent to the previous forum threads you have posted in.

    I have attached a screen cast where I use this control. Please take a look at it and see if that is the desired behavior. If this is the case, please take a look at my response in the following forum thread - http://www.sitefinity.com/support/forums/sitefinity-3-x/developing-with-sitefinity/displaying-a-single-news-item.aspx

    Greetings,
    Rado
    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.
Register for webinar
7 posts, 0 answered