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

Forums / Bugs & Issues / Getting all events by Title

Getting all events by Title

13 posts, 1 answered
  1. Kieran
    Kieran avatar
    56 posts
    Registered:
    14 Aug 2008
    17 May 2010
    Link to this post
    Hi

    I am trying to get an event by name. 

    My approach was to get all the event and compare their names to the name I'm looking for.

    // create new instance of EventsManager
    Telerik.Events.EventsManager eventsManager = new Telerik.Events.EventsManager("Events");
    // get all events
    IList listOfAllEvents = eventsManager.GetEvents();
    if (listOfAllEvents.Count > 0)
    {
       foreach (Telerik.Events.IEvent eventItem in listOfAllEvents)
           if(eventItem.EventTitle == "MY EVENT NAME")
           {
              Thats my event;
              break;
           }
     
     
    }

    I am using Sitefinity 3.7. Is there something after changing as this used to work fine for older versions.


    Thanks
    Kieran


  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 May 2010
    Link to this post
    Hi Kieran,

    You could use GetMetaData("Title") of an IContent item instead of EventTitle, but the code looks fine.

    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.
  3. Kieran
    Kieran avatar
    56 posts
    Registered:
    14 Aug 2008
    17 May 2010
    Link to this post
    Hi Ivan

    Thanks for the reply.


    I am getting an error
    Using the generic type 'System.Collections.Generic.IList<T>' requires '1' type arguments


    on 

    IList listOfAllEvents = eventsManager.GetEvents();


    Any idea

    Kieran

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 May 2010
    Link to this post
    Hello Kieran,

    The IList type you use is not correct use

    System.Collections.IList listOfAllEvents = eventsManager.GetEvents();


    Kind 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.
    Answered
  5. Kieran
    Kieran avatar
    56 posts
    Registered:
    14 Aug 2008
    18 May 2010
    Link to this post
    Thanks Ivan, that worked.

    Another Q on events. I have linked to an external template to display the event details using the sitefinity events module. Is there anyway to get the ID of the event to be displayed. I am able to display everything - Title dates metafields etc.


    Thanks
    Kieran


  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 May 2010
    Link to this post
    Hello Kieran,

    The control has two modes

    master - displays all events in a list
    details - display a single event

    Also the control has about 4 Presentation modes.

    So. the answer to your question really depends on the mode you use - master/detail.

    Kind 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.
  7. Kieran
    Kieran avatar
    56 posts
    Registered:
    14 Aug 2008
    18 May 2010
    Link to this post
    Sorry,

    I am using the details mode - display a single event

    Thanks
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 May 2010
    Link to this post
    Hello Kieran,

    You can add the following  code to ListPageDetails.ascx template which shows the details mode of a given event. The code will return the ID of the item that is being displayed and the content item if necessary

    if (Context.Items.Contains(Manager.Provider.ContentItemKey))
        {
            var itemId = (Guid)((IUrlRewriteData)Context.Items[Manager.Provider.ContentItemKey]).Data;
            cntManager = new ContentManager("YOUR PROVIDER HERE");
            IContent cnt = cntManager.GetContent(itemId);
            // set the Full Results here
        }


    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.
  9. Kieran
    Kieran avatar
    56 posts
    Registered:
    14 Aug 2008
    18 May 2010
    Link to this post
    Thanks Ivan,

    Below is  the ListPageDetails.ascx I use there is no code behind for me to place the above code.
    Where would I place this code.



    <div class="sf_singleEvent">
        <div class="sf_eventBasicInfo">
            <table id="event">
                <thead>
                    <tr>
                        <th colspan="2">
                            <h3 id="EventName">
                                <asp:Literal ID="Title" runat="server" />
                            </h3>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td width="70%">
                            <p>
                                 <asp:Literal ID="ContentID" runat="server" />
                                <strong>
                                    Date: <asp:Literal runat="server" ID="Event_Start"/>
                                    <br />
                                    Location: 
                                    <asp:Literal ID="Street" runat="server" /></strong><br />
                            </p>
                        </td>
                        <td class="price">
                            <p>
                                <strong> Member Price:<br />
                                    €<asp:Literal ID="MemberPrice" runat="server" /> per person</strong></p>
                                      
                            <p>
                                <strong> Member Price:<br />
                                €<asp:Literal ID="NonMemberPrice" runat="server" /> per person</strong></p>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <p>
                                <strong>About This Event</strong><br />
                                <asp:Literal ID="content" runat="server" /></p>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <p>
                                <strong>Contact Details</strong><br />
                                <asp:Literal ID="Contact_Name" runat="server" Text="{0}" /><br />
                                Email:
                                <asp:Literal ID="Contact_Email" runat="server" Text="<a href='mailto:{1}'>{0}</a>" /><br />
                                Phone:
                                <asp:Literal ID="Contact_Phone" runat="server" Text="{0}" /><br />
                                Mobile:
                                <asp:Literal ID="Contact_Cell" runat="server" Text="{0}" /><br />
                                Website:
                                <asp:Literal ID="Contact_Web" runat="server" Text="<a href='http://{1}'>{0}</a>" /></p>
                        </td>
                    </tr>
                    <tr>
                        <td width="30%"
                        </td>
                        <td>
                            <asp:HyperLink ID="backToList1" Text="Return to Events Listing" CssClass="back-to-list"
                                runat="server"></asp:HyperLink>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>



    Thanks
    Kieran
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 May 2010
    Link to this post
    Hi Kieran,

    Create a code behind of the template or write the code inline. You could add it inside PreRender

    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.
  11. Kieran
    Kieran avatar
    56 posts
    Registered:
    14 Aug 2008
    18 May 2010
    Link to this post
    Hi Ivan,

    Hopefully this will be the last stupid question from me.

    Whats the Manager that you refer to here

        Manager.Provider.ContentItemKey.




    <script runat="server">
         
        protected void Page_PreRender(object sender, EventArgs e) 
        {
            if (Context.Items.Contains(Manager.Provider.ContentItemKey))
            {
                var itemId = (Guid)((Telerik.Web.IUrlRewriteData)Context.Items[Manager.Provider.ContentItemKey]).Data;
                Telerik.Cms.Engine.ContentManager cntManager = new Telerik.Cms.Engine.ContentManager("Events");
                Telerik.Cms.Engine.IContent cnt = cntManager.GetContent(itemId);
                // set the Full Results here
            }  
        
          
    </script>


    Thanks
    Kieran
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 May 2010
    Link to this post
    Hi Kieran,

    Create a new instance of ContentManager

    Telerik.Cms.Engine.ContentManager Manager = new Telerik.Cms.Engine.ContentManager("Events");


    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.
  13. Kieran
    Kieran avatar
    56 posts
    Registered:
    14 Aug 2008
    18 May 2010
    Link to this post
    Excellent stuff

    Thanks for the help Ivan


    Kieran
Register for webinar
13 posts, 1 answered