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

Forums / Developing with Sitefinity / Displaying a Single News Item

Displaying a Single News Item

19 posts, 0 answered
  1. Armysniper
    Armysniper avatar
    126 posts
    Registered:
    03 Mar 2005
    23 Feb 2009
    Link to this post
    I would like to be able to display a single news item on a page. In our current site, each news item (article in our world) is displayed on a separate page. How can I use the NewView or another control, to display only a specified news article and not a list? Ideally this would be something the content authors can use.
  2. Nikolai
    Nikolai avatar
    216 posts
    Registered:
    01 Jun 2017
    24 Feb 2009
    Link to this post
    Hello,

    There to ways to do that.
    First:
    1. Create News Items from the News Module. Each news item should be in separated Category.
    2. Use the News View control and filter by Category - since only one item uses this category only one item will be shown.

    Second:
    1. Create you news items. No category is needed.
    2. Place the News View Control on the page and click Edit.
    3. Go to the Advanced Tab -> Filters
    4. Add the following line: AND Title = "the title of your news item"
    This way the News View Control will only show news items having Title you define, please note that you can have multiple items with the same title so all of them will be shown.

    Greetings,
    Nikolai
    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. Armysniper
    Armysniper avatar
    126 posts
    Registered:
    03 Mar 2005
    24 Feb 2009
    Link to this post
    I think I will go with the filters. Is there a possibility of getting a single news page control developed that will allow the user to select a specific article?

    Also, how can I change the styles of the news article? I have very specific style sheet styles I need to implement for the title as well as the content itself.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    24 Feb 2009
    Link to this post
    Hello Armysniper,

    Thank you for using our services.

    You can use NewsView control and add a texbox and a button. Then your users could filter the news by the appropriate operand that could be pre defined as well( youcan use a drop down instead of a textbox). This could be done for the public part, or you can directly set what should be shown from the control properties as Nikolay has described in his post.
    The style of the news could be changed through the following file ~/Sitefinity/ControlTemplates/News/newsCommonLayout.css

    Sincerely yours,
    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.
  5. Armysniper
    Armysniper avatar
    126 posts
    Registered:
    03 Mar 2005
    27 Feb 2009
    Link to this post
    Thanks for the part about the style sheet. That will help alot. What I meant by "user" in my previous post was the Content Author...not a regular user. I want to enable my Content Authors to come in create a page, add the News View control (or another control that is built simply for displaying a single news item) and having a way for them to add a single news item from a list of news items. They would find the one they want and it would be displayed in the control and they can publish.
  6. Armysniper
    Armysniper avatar
    126 posts
    Registered:
    03 Mar 2005
    02 Mar 2009
    Link to this post
    I went with the model of using the Filters to narrow down my page to a single article but it still only shows a summary. How can I get it to display the entire page?
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    02 Mar 2009
    Link to this post
    Hi Armysniper,

    Generally, NewsView control Summary, Content, Author etc. are set through the control designer, News setting ssection. Have you checked these checkboxes?

    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.
  8. Armysniper
    Armysniper avatar
    126 posts
    Registered:
    03 Mar 2005
    02 Mar 2009
    Link to this post
    If I leave them as default, I only get the summary. If I uncheck Summary, I get NOTHING. If I leave Content checked or unchecked it has not factor. I got the filter to work so it displays the proper topic, but I want it to display the entire topic not just the summary. Is there a single news item control that I can subclass that you guys use to simply get a news item to display on a page?
  9. Armysniper
    Armysniper avatar
    126 posts
    Registered:
    03 Mar 2005
    02 Mar 2009
    Link to this post
    Ivan, I am running 3.6 and there is no style sheets in the News folder anymore under Control Templates. How can I modify this?
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    03 Mar 2009
    Link to this post
    Hello,

    If you want to use external templates you have to map them. Then you will be able to modify the code. The title of a news item is set through the control designer by default. The checkbox control is disabled there, so the title is always visible.

    Kind regards,
    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.
  11. Armysniper
    Armysniper avatar
    126 posts
    Registered:
    03 Mar 2005
    03 Mar 2009
    Link to this post
    For the title, all I want is to specify a class from my style sheet. Thats it. Can I do that in the designer?
  12. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    07 Mar 2009
    Link to this post
    Hi,

    Selecting the CSS Class for your Title from the Designer is not possible out of the box. There are several approaches you might use now:
    1. Drag the NewsView control in content place holder, wrapped in div container, having a CSS class already defined for the Title element;
    2. Setting the Css class in the template;
    3. Customizing the Designer. This is the hardest among the options here. We have an example, showing you how to add CSS definition to one of the Designer controls. This is almost what you want actually - please take a look at Working with ContentView designer (part 5): Implementing custom designer CSS setting.

    Don't hesitate to contact us if you have other questions.

    Sincerely yours,
    Georgi
    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.
  13. Nitesh Rastogi
    Nitesh Rastogi avatar
    15 posts
    Registered:
    24 Aug 2009
    02 Sep 2009
    Link to this post
    Hi Nikolai,

    I am using the news control provided by the jet30 application which i got from the www.sitefinitywatch/notes.aspx.
    This control displays all the news titles.My req is when i click on a particular title the news related to that should open in a new page.What changes do i have to make in the code.

    Can you please guide me the steps or send some sample code for the same.

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

    Thank you for using our services.

    I have taken a look at the user controls from the webinar you are referring to. If I understand correctly you want to use the ~/jet30-download/Custom/UserControls/News.ascx, do you. If that is so, here is what you can do. After you have added this control to your tool box, go to a page and simply add it to the page. Now this control is hardcoded to open the news items in a page called ~/news.aspx. Does not matter on which page you add it, it will always open single news items in ~/news.aspx page. all you have to do to your project is to create a pages and call it news.aspx. Then just place a news view control on that page.

    If in your project you have another page to display your news items you should modify a little bit the code file for the ~/jet30-download/Custom/UserControls/News.ascx control. If that is the case, go to ~/jet30-download/Custom/UserControls/News.ascx.cs. You will have to provide the URL to your page in the NewsRepeater_OnItemDataBound method like this:
    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 = "~/yourpage/" + linkinfo.Url; 
                itemLink.InnerText = linkinfo.Title; 
            } 
        } 

    If you have more questions, please feel free to contact us.

    Sincerely yours,
    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.
  15. Nitesh Rastogi
    Nitesh Rastogi avatar
    15 posts
    Registered:
    24 Aug 2009
    02 Sep 2009
    Link to this post
    Hi Rado,

    Thanks for the info.

    Would also like to know if it is mandatory to use the news view control on the page where i am displaying the full news content or is there is a way where by i can show the full news  description without the news view control. As i do not need the All News , Full story ,the dates and the list of images displayed by the news view control.Kindly post any code for the same.

    Would also like to know as i require to see only one news content at a time , so any specific settings to be made.

    Please suggest an alternate solution for the same.

    Thanks
  16. Nitesh Rastogi
    Nitesh Rastogi avatar
    15 posts
    Registered:
    24 Aug 2009
    02 Sep 2009
    Link to this post
    Hi Rado,

    I have implemented the change recomended by you, but when i hover over the title it shows the http://localhost/TestSitefinity/news/09-09-01/Test_new_news link formed and when i click on the same it takes me to an empty page.I have created a page in SF by name news and placed a news view control on it.
    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;  
            }  
        } 

    Is there anything else i have to do. Also is there a way to accomplish the task without using the news view control.As i do not need the All News , Full story ,the dates and the list of images displayed by the news view control.Kindly post any code for the same.

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

    I think I have already mentioned that you need to place a News View control on that page. If you only want to display news details, just click Edit of the news view, go Advanced and select BehaviorMode to be Detail.

    Kind regards,
    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.
  18. Nitesh Rastogi
    Nitesh Rastogi avatar
    15 posts
    Registered:
    24 Aug 2009
    02 Sep 2009
    Link to this post
    Hi Rado,

    Thanks for your support.

    I have implemented the change recomended by you, but when i hover over the title it shows the http://localhost/TestSitefinity/news/09-09-01/Test_new_news link formed and when i click on the same it takes me to page not found.I have created a page in SF by name news and placed a news view control on it.
    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;  
            }  
        } 

    Is there anything else i have to do or am i missing anything..

    Thanks
  19. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    02 Sep 2009
    Link to this post
    Hello Nitesh Rastogi,

    As I see it the link is now well formed. There is no extension. I suggest that you should use linkinfo.UrlWithExtension.

    Regards,
    Ivan Dimitrov
    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
19 posts, 0 answered