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

Forums / General Discussions / Custom News View And Detail

Custom News View And Detail

23 posts, 1 answered
  1. Sam
    Sam avatar
    21 posts
    Registered:
    18 Aug 2010
    21 Sep 2010
    Link to this post
    I've created a custom news "reel" that is going to be displayed on the homepage.  I get all of the news items from the news provider, and then use the URL property on the content.

    How do I send it over to a detail page to view just that list item?  Or a list of news items with that element as the focus.  I dropped a news view control onto the page, but nothing is showing up.

    Any additional resources would be appreciated!

    Thanks,

    Sam Ferrise
    sam.ferrise@fireflylogic.com

    EDIT: I'm using the Url property on the news item, and it's generating "http://localhost/10-09-21/Test_News_Item" - I guess I just need to know how to direct that to a detail view, a different one per element.  Additionally, we will have three news pages, one for each main category that needs to have the same behavior.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    21 Sep 2010
    Link to this post
    Hello Sam,

    By default our NewsView control has its own rewriting and routing which allows you to see master mode - list of items and details mode - single item. If you have your own custom control the easiest way to achieve master/detail mode functionality is adding a PlaceHolder control inside the template where you show all items. Inside this PlaceHolder you have to add controls that will shows the selected IContent item data. In the list mode you should append the item url or item ID as a query string when you click on "full story" link. Then you have to read the query string data, hide the repeater ( or another control ) that you use to show list of items and show the PlaceHolder that will be to present your single item data.

    You can take a look at this post - Getting your News articles full Urls

    Sincerely yours,
    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. Sam
    Sam avatar
    21 posts
    Registered:
    18 Aug 2010
    21 Sep 2010
    Link to this post
    Thanks!  I ended up doing something quite similar.  I created a news item detail page, and when I built the URL for the "Read More" link, I gave it that URL + the NewsItem query string parameter.

    I love the extensibility with this product - you guys have done a great job.  And the support is awesome!
  4. Keith
    Keith avatar
    67 posts
    Registered:
    13 Sep 2010
    25 Oct 2010
    Link to this post
    Hi,
    I am doing something very similar to this but I am not using a custom news list view control - just the default one in Sitefinity.  I do however need to use a custom page to view the details of the news article.  Among other things, this page will need to write the name of the viewed article to an external database.  Is there a way that I can just inherit the base functionality of the details view control to accomplish this extra functionality?
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Oct 2010
    Link to this post
    Hi Keith,

    You can map the external template for details mode - ListPageDetail.ascx and create a code behind of it. Then you can get the content item from the context and get its metadata by using GetMetaData method of the IContent item.

    if (Context.Items.Contains(Manager.Provider.ContentItemKey))
      itemId = (Guid)((IUrlRewriteData)Context.Items[Manager.Provider.ContentItemKey]).Data;


    Greetings,
    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
  6. Keith
    Keith avatar
    67 posts
    Registered:
    13 Sep 2010
    25 Oct 2010
    Link to this post
    Hi thanks for the quick reply

    I am a little bit confused about what I am a little bit confused about what  exactly Manager.Provider.ContentItemKey should be...
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Oct 2010
    Link to this post
    Hi Keith,

    This is an instance of the ContentManger where you should pass "News" as a provider name.

    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
  8. Keith
    Keith avatar
    67 posts
    Registered:
    13 Sep 2010
    25 Oct 2010
    Link to this post
    I put the following into my code behind for the single item template under Page_Load:
    ContentManager cm = new ContentManager("News");
    Guid itemID = new Guid();
    if (Context.Items.Contains(cm))
        itemID = (Guid)((IUrlRewriteData)Context.Items[cm]).Data;
    IContent newsitem = cm.GetContent(itemID);
    Response.Write(newsitem.GetMetaData("Title"));

    and I get "Object reference not set to an instance of an object."
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Oct 2010
    Link to this post
    Hello Keith,

    One of the objects is null and you use it in the code.

    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
  10. Keith
    Keith avatar
    67 posts
    Registered:
    13 Sep 2010
    25 Oct 2010
    Link to this post
    Well, yes, but why is it null? Am I implementing this properly?
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Oct 2010
    Link to this post
    Hello Keith,

    You are checking for manager in the Context.Items collection instead of ContentItemKey. Please review my sample again.

    Greetings,
    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
  12. Keith
    Keith avatar
    67 posts
    Registered:
    13 Sep 2010
    25 Oct 2010
    Link to this post
    I still don't get what ContentItemKey is supposed to be...
    where do i get ContentItemKey from?
  13. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Oct 2010
    Link to this post
    Hello Keith,

    Ok, try another way. Create a code behind of ListPageDetails.ascx template and access the Text of the Literal control with ID="Title".

    <asp:Literal ID="Title" runat="server"></asp:Literal>

    Then seve this value to the other database.

    Regards,
    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
  14. Keith
    Keith avatar
    67 posts
    Registered:
    13 Sep 2010
    25 Oct 2010
    Link to this post
    Ok that way works...

    I still would like to know what ContentItemKey is too...it would be nice to know how do do it that way in case I need to do it in the future rather than just reading in the text from a server tag.
  15. man
    man avatar
    6 posts
    Registered:
    21 Jun 2012
    16 Nov 2011
    Link to this post

    Hi,

    i am new to sitefinity and using for developing a website, i have created new article and now i need to write a custom code while save the news. the process is

    1. based on the user role i need to set the news flag as global or local news.
    2. based on the user i need to show the language available for the particular news.
    3. after saving the news, i need to send an email with the news content to particular users, user will be taken from the database tables.

    i tried for the code, but i cannot able to write custom code for the news pages.

  16. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 Nov 2011
    Link to this post
    Hello Man,

    You can subscribe for ContentManager.Executing or ContentManager.Executed inside Application_Start of Global.asax and execute your logic there.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  17. man
    man avatar
    6 posts
    Registered:
    21 Jun 2012
    17 Nov 2011
    Link to this post
    hi Ivan Dimitrov

    Thanks for your reply..

    i seen several post and i did not get an idea regarding writing custom code. can you provide me a sample to write custom code.

    for example: if i need to add a field in news gridview. see the image attached.

    i need to do some fields adding and controlling the fields based on user roles.


    Thanks
  18. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    21 Nov 2011
    Link to this post
    Hi Man,

    You can add new columns to an existing grid through configurations.

    You can control permissions for content item or roles using Permissions screen for each item or global permissions available at ~/Sitefinity/Administration/Permissions

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  19. man
    man avatar
    6 posts
    Registered:
    21 Jun 2012
    21 Nov 2011
    Link to this post
    Hi Ivan Dimitrov ,

    Thanks for your reply and going on development on this news module.I done the settings changes and  yours reply helped me a lot.

    now i need to add a custom column and should be hidden in news module, say a dropdown with Global or Local news.
               -- Need to visible or invisible the Field based on user role.
               -- Need to send the value based on user role to database  while saving.

    this is major functionality i need to have in News Module.

    Once again Thanks for your reply and help.


    Thanks
    Manoj
  20. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    23 Nov 2011
    Link to this post
    Hi Man,

    -- Need to visible or invisible the Field based on user role.

    Currently you see the menu item and when a user clicks on it, they will get a message that rules do not allow this operation.

    -- Need to send the value based on user role to database  while saving.

    There are global events triggered when you save a content item. You can access them though Global.asax - NewsManager.Executed and NewsManager.Executing.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  21. man
    man avatar
    6 posts
    Registered:
    21 Jun 2012
    25 Nov 2011
    Link to this post
    Hi Ivan Dimitrov ,

    Thanks for your reply, and now i can able to override the news publish method and i can able to do my functionalists.. Thanks..

    i seen about web services, News web service which can be used to get and set the values of the news item. i need to web service name and method to get the news details and save the same to another database.

    since my requirement is,

    i am having 2 database, while saving the news item, images, categories and tags i need to save it both the database.

    can we use service or is there any method available to do this.

    Thanks

  22. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Nov 2011
    Link to this post
    Hello Man,

    I can suggest two ways

    1. though Global.asax - NewsManager.Executed and NewsManager.Executing
    2. Creating a custom class that inherits from the data provider NewsDataProvider and there you override Create/Delete/Edit methods and implement logic for persisting data in your custom database.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  23. man
    man avatar
    6 posts
    Registered:
    21 Jun 2012
    25 Nov 2011
    Link to this post
    Hi Ivan Dimitrov ,

    thanks for your reply...

    as you told in previous post, i tried the NewsManager.Executed and NewsManager.Executing method in global.ascx file.
    but i am not getting the exact way to process.

    i can override the publish method and getting it. but cannot able to do this.

    i created a data provider for the connection string. but i need to way to approach it. can you give a sample code for doing this.


    Thanks
    Manoj
Register for webinar
23 posts, 1 answered