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

Forums / Designing with Sitefinity / Voting on a news item

Voting on a news item

2 posts, 0 answered
  1. Stuart Hemming
    Stuart Hemming avatar
    144 posts
    Registered:
    07 Jul 2004
    03 Jan 2011
    Link to this post
    I want to allow readers to vote on a question based on a news item.

    Can I add a poll to a news page?

    -- 
    Stuart
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    03 Jan 2011
    Link to this post
    Hello Stuart,

    Poll and News are two different types and they are not related. You can easily make a relation to a poll from a news item ( IContent) by using a  custom metafiled where you add the poll ID, but it would be hard to find the news item from the poll item. The last one will require to create a custom field in polls and enter the news ID there. You can create a simple custom data layer that uses [sf_Polls_PollData]  table where you inject the news ID when an item is created or updated and delete the item ID when the news item is deleted.

    If you want to connect poll answers with news items you should use [sf_Polls_AnswerData]

    ContentManager class has static event "Executed" which  you can use to catch when an item is updated, created or deleted. You can subscribe for this event inside Global.asax, Application_Start

    sample


    void Application_Start(object sender, EventArgs e)
       {
           // Code that runs on application startup
           Telerik.Cms.Engine.ContentManager.Executed += new EventHandler<Telerik.ExecutedEventArgs>(ContentManager_Executed);
     
           
       }
     
      void ContentManager_Executed(object sender, Telerik.ExecutedEventArgs e)
       {
           if (e.CommandName == "UpdateContent" || e.CommandName == "CreateContent")
           {
               var providerName = (e.Data as Telerik.Cms.Engine.Data.CmsContentBase).ProviderName;
               if (providerName == "News")
               {
                   var itemID = e.ItemID;
                   var itemName = (e.Data as Telerik.Cms.Engine.Data.CmsContentBase).Name;
               }
           }


    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