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

Forums / Designing with Sitefinity / Custom Event View

Custom Event View

18 posts, 0 answered
  1. Drew Reutlinger
    Drew Reutlinger avatar
    17 posts
    Registered:
    25 Sep 2009
    23 Feb 2010
    Link to this post
    I am following the instructions to map an external template and have performed all the steps outlined in the developer's manual. I'm attempting to customize the list of events layout.

    My ControlsConfig.xml file looks like this:

    <?xml version="1.0" encoding="utf-8" ?>
    <controlsConfig>
      <viewMap>
     
        <viewSettings hostType="Telerik.Events.WebControls.EventsView">
          <additionalTemplates>
            <!--Item List-->
            <add key="ItemListTemplatePath" layoutTemplatePath="~/Sitefinity/ControlTemplates/Events/ContentViewItemView.ascx" />
            <!--Single Item-->
            <add key="SingleItemTemplatePath" layoutTemplatePath="~/Sitefinity/ControlTemplates/Events/ContentViewSingleItemView.ascx" />
          </additionalTemplates>
        </viewSettings>
      </viewMap>
     
    </controlsConfig>

    I placed the templates in the correct directory and restarted IIS.

    Any changes that I do to the files have no effect on the site. Is there another setting that I missed?

    ***** Update *****

    I mapped the external templates through events admin panel and is now displaying my changes. Is this a step that is required? If so, shouldn't it be included in the developer's manual?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    23 Feb 2010
    Link to this post
    Hi Drew Reutlinger,

    Map the templates through EventsView control designer - Appearance section - ItemListTemplatePath and SingleItemTemplatePath properties or modify the ControlsConfig templates keys to  ItemListTemplate and SingleItemTemplate.

    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.
  3. Venkat
    Venkat avatar
    105 posts
    Registered:
    20 Nov 2008
    14 Dec 2010
    Link to this post
    Hi

    In our application We need to filter Events by category.
    Categories are shown in a drop down list,when ever we change the dropdown selection, I am changing the the EventsView object's filter expression and calling it DataBind method.

    Here I created an object for  the EventsView in Code behind class and adding it to my place holder dynamically.
    I am not using Admin's Events view control  tool to display events,rather I am adding it through the code.

    When I try to view the events on the page it is giving the eror

    Events View control cannot be previewed in design mode.

    How can I change EventViews's design mode , and why it is saying that it's a preview.

    I did same for NewsView, it is working fine.But EventsView not displaying .

    my code:

     EventsView eventsView;

    eventsView.FilterExpression="Publication_Date <= \"#now\" AND Expiration_Date > \"#now\" AND Category like \"" + ddlEventCategories.SelectedValue + "\" ";
          
     eventsView.DataBind();

    Please advise me on this.
    Thanks
    Venkat
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    14 Dec 2010
    Link to this post
    Hello Venkat,

    When I try to view the events on the page it is giving the eror Events View control cannot be previewed in design mode.

    This is message that we show, because in edit mode the page is null and we "disable" CreateChildControls. You should not call DataBind of the control, you have to add it to Controls collection only.

    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
  5. Venkat
    Venkat avatar
    105 posts
    Registered:
    20 Nov 2008
    15 Dec 2010
    Link to this post
    Hi Ivan,
    Greetings to you and thank you for your reply.
    I have removed the DataBind statement ,Now It is working fine.

    I want to add my own custom template to show the Events,Can you please provide me the download link which contains all control templates.

    Thanks
    Venkat
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Dec 2010
    Link to this post
    Hello Venkat,

    Here is a link to downloads section of your account from where you can download external templates.

    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. Venkat
    Venkat avatar
    105 posts
    Registered:
    20 Nov 2008
    15 Dec 2010
    Link to this post
    Thank you Ivan, I have searched for it for 3 hours.

    Venkat.
  8. Venkat
    Venkat avatar
    105 posts
    Registered:
    20 Nov 2008
    15 Dec 2010
    Link to this post
    Ivan,
    After adding external template 'ContentViewItemView.ascx' in the events control template section,
    My EventsView control which I am adding dynamically through code, displaying nothing.

    Even after reverting the code (i have removed the entries in the 'Telerik.Sitefinity.Configuration.ControlsConfig.xml' ) too , it is not displaying events.
    Here is my code:

    eventsView = new EventsView();
    eventsView.FilterExpression="Publication_Date <= \"#now\" AND Expiration_Date > \"#now\" AND Category like \"" + ddlEventCategories.SelectedValue + "\" ";
     I am adding this control to a parent control.Can you please explain me the reason and guide me on this.
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Dec 2010
    Link to this post
    Hello Venkat,

    You can use SingleItemTemplatePath property of the control to set its template.

    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
  10. Venkat
    Venkat avatar
    105 posts
    Registered:
    20 Nov 2008
    15 Dec 2010
    Link to this post
    Ivan,

    Even If I not set this property,It will take the default template, i think. any way I reverted my code and not using external templates.But still not showing the events.

    can you please give me example code lines to add EventsView  control through code.

    Thanks
    Venkat
  11. Venkat
    Venkat avatar
    105 posts
    Registered:
    20 Nov 2008
    16 Dec 2010
    Link to this post
    Ivan,
    Now I have two issues with Adding NewsView and EventsView throught code.

    NewsView:
    NewsView is displaying all the  news items filtered by selected news category dropdown.But when I click on the full story link ,it is saying that the page is not found.How can I view single item page which is generated automatically.
    same problem with eventsview also.

    EventsView:
    If I give filter expression it is giving nothing.If I omit the FilterExpression it is displaying all events.irrespective of event category selection.How can I display on events belnogs to dropdown selection


    Here is my NewsView  and Events View Code:

    if (!IsPostBack)

            {

                BindNewsCategories();

                BindEventCategories();

            }

            EventsView eventsView = new EventsView();

            //eventsView.SelectedCategories = new string[] { ddlEventCategories.SelectedValue };       

            eventsView.ItemListTemplatePath = "~/Sitefinity/ControlTemplates/Events/ContentViewItemView.ascx";

            eventsView.SingleItemTemplatePath = "~/Sitefinity/ControlTemplates/Events/ContentViewSingleItemView.ascx";

             eventsView.FilterExpression="Publication_Date <= \"#now\" AND Expiration_Date > \"#now\" AND Category In (\"" + ddlEventCategories.SelectedValue + "\" )";       

            //eventsView.DataBind();

            NewsView newsView = new NewsView();

            newsView.ItemListTemplatePath = "~/Sitefinity/ControlTemplates/News/Modes/ListPageMaster.ascx";

            newsView.SingleItemTemplatePath = "~/Sitefinity/ControlTemplates/News/Modes/ListPageDetails.ascx";

            newsView.BookmarkEnabled = false;

            newsView.AllowComments = false;

            newsView.AllowPaging = false;

            newsView.FilterExpression = "Publication_Date <= \"#now\" AND Expiration_Date > \"#now\" AND Category like \"" + ddlNewsCategories.SelectedValue + "\" ";

            newsView.DataBind();

           ucTabControl.AddTab("All News", newsView);

            ucTabControl.AddTab("Events", eventsView);

    }

  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    20 Dec 2010
    Link to this post
    Hello Venkat,

    1. If this is a user control you should add the following attribute to it.

    [Telerik.Web.UrlRewriterService("Telerik.Cms.Engine.ContentUrlRewriterService, Telerik.Cms.Engine")]

    2. Please verify that ddlNewsCategories.SelectedValue returns a value and you do not have to call newsview.DataBind();

    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
  13. Venkat
    Venkat avatar
    105 posts
    Registered:
    20 Nov 2008
    21 Dec 2010
    Link to this post
    Ivan,
     Here is my code:
    EventsView eventsView = new EventsView(); 
            //eventsView.SelectedCategories = new string[] { ddlEventCategories.SelectedValue };        
      
            eventsView.ItemListTemplatePath = "~/Sitefinity/ControlTemplates/Events/ContentViewItemView.ascx";
      
            eventsView.SingleItemTemplatePath = "~/Sitefinity/ControlTemplates/Events/ContentViewSingleItemView.ascx";
      
             eventsView.FilterExpression="Publication_Date <= \"#now\" AND Expiration_Date > \"#now\" AND Category In (\"" + ddlEventCategories.SelectedValue + "\" )";        

    When the page loads I am setting the filter expression, but it is not filtering at all.

    Thanks
    Venkat
  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    21 Dec 2010
    Link to this post
    Hi Venkat,

    I checked this setup and if you do not see the correct item in the list then you are not passing correct value by using ddlEventCategories.SelectedValue.


    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
  15. Venkat
    Venkat avatar
    105 posts
    Registered:
    20 Nov 2008
    21 Dec 2010
    Link to this post

    Ivan,
    Our user control contains NewsView control (added dynamically by code)
    I am setting its filter expression and adding it to my user control place holder.
    So How can I use the below code snippet in my user control.?

    [Telerik.Web.UrlRewriterService("Telerik.Cms.Engine.ContentUrlRewriterService, Telerik.Cms.Engine")]

    Thanks
    Venkat
  16. Venkat
    Venkat avatar
    105 posts
    Registered:
    20 Nov 2008
    23 Dec 2010
    Link to this post
    Hi Ivan,Thank you for your replies.

    Here I am sending you my code drop.please look into it and guide me on these below issues.

    1). EventView Filtering not working when I filter it by Category.
    2). NewsView  Filtering by Category is working perfect and displaying the filtered items.but full story link not working.Even when I click on the title , its redirecting to the auto generated page link but giving the error

    The resource cannot be found.


    Please guide me on this.
    Thanks
    Venkat

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.News.WebControls;
    using Telerik.Events.WebControls;
    using Telerik.News;
    using System.Collections;
    using Telerik.Cms.Engine;
    using Telerik.Security;
    using Telerik.Events;
    using Telerik.Cms.Engine.WebControls.Design;
    using Telerik.Cms.Engine.Design;
     
    [Telerik.Web.UrlRewriterService("Telerik.Cms.Engine.ContentUrlRewriterService, Telerik.Cms.Engine")]
    public partial class UC_NewsAndEvents : System.Web.UI.UserControl
    {
          
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindNewsCategories();
                BindEventCategories();
            }
            EventsView eventsView = new EventsView();
            eventsView.SelectedPresentationMode.ModeTitle = "Expandable list";
           

            eventsView.SelectedPresentationMode.CssClass = "expandableList";
            eventsView.SelectedPresentationMode.MasterTemplateName = "Telerik.Events.Resources.ControlTemplates.Frontend.Modes.ExpandableListMaster.ascx";
            //eventsView.SelectedCategories = new string[] { ddlEventCategories.SelectedValue };
            eventsView.ItemListTemplatePath = "~/Sitefinity/ControlTemplates/Events/ContentViewItemView.ascx";
            eventsView.SingleItemTemplatePath = "~/Sitefinity/ControlTemplates/Events/ContentViewSingleItemView.ascx";
            eventsView.FilterExpression="Publication_Date <= \"#now\" AND Expiration_Date > \"#now\" AND Category In (\"" + ddlEventCategories.SelectedValue + "\" )";
            //eventsView.DataBind();
     
            NewsView newsView = new NewsView();
            newsView.ItemListTemplatePath = "~/Sitefinity/ControlTemplates/News/Modes/ListPageMaster.ascx";
            newsView.SingleItemTemplatePath = "~/Sitefinity/ControlTemplates/News/Modes/ListPageDetails.ascx";
            newsView.BookmarkEnabled = false;
            newsView.AllowComments = false;
            newsView.AllowPaging = false;
            newsView.FilterExpression = "Publication_Date <= \"#now\" AND Expiration_Date > \"#now\" AND Category like \"" + ddlNewsCategories.SelectedValue + "\" ";
            newsView.ItemListUrl = "~/AboutUs/Press.aspx";
           newsView.DataBind();
            
            ucTabControl.AddTab("All News", newsView);
            ucTabControl.AddTab("Events", eventsView);
        }
     
           
        private void BindEventCategories()
        {
            EventsManager eventManager = new EventsManager("Events");
            IList listOfCategories = eventManager.Content.GetCategories(0, 100, "CategoryName ASC");
            if (listOfCategories.Count > 0)
            {
                foreach (ICategory catItem in listOfCategories)
                {
                    ddlEventCategories.Items.Add(catItem.CategoryName);
                }
         
            }
            ddlEventCategories.SelectedValue = "Press";
        }
     
     
        private void BindNewsCategories()
        {
            NewsManager newsManager = new NewsManager("News");
            IList listOfCategories = newsManager.Content.GetCategories(0, 100, "CategoryName ASC");
            if (listOfCategories.Count > 0)
            {
                foreach (ICategory catItem in listOfCategories)
                {
                    ddlNewsCategories.Items.Add(catItem.CategoryName);
                }
                 
     
            }
            ddlNewsCategories.SelectedValue = "Press";
        }
     
        protected void ddlEventCategories_SelectedIndexChanged(object sender, EventArgs e)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "showEvents", "showEvents();", true);
        }
    }
  17. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    23 Dec 2010
    Link to this post
    Hello ,

    If you still get this error, please make sure that the url RewriteFormat is valid and you can try to move the logic in a custom control instead of using a user control.

    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
  18. Venkat
    Venkat avatar
    105 posts
    Registered:
    20 Nov 2008
    23 Dec 2010
    Link to this post
    Ivan,
    I have figured out the problem and solution with event filter on category

    if i use
    eventsView.FilterExpression = string.Format("Publication_Date <= \"#now\" AND Expiration_Date > \"#now\" AND Category LIKE {0}",ddlEventCategories.SelectedValue);

    Then it is working fine.please note  in the above expression after LIKE, I have removed the double quotes around the category keyword.If I give the filter expression as shown below it is not working.
    eventsView.FilterExpression = string.Format("Publication_Date <= \"#now\" AND Expiration_Date > \"#now\" AND Category LIKE \"{0}\"",ddlEventCategories.SelectedValue);

    But here the problem is If a category having name with more than one word separated by space, it is giving error as I am not using the quotes around the key word.

    I have added  NewsView Init method and Binding it to get proper values other wise I am getting the values of previously selected dropdown selected value. here is my Init method.
    eventsView.Init += new EventHandler(eventsView_Init);
    void eventsView_Init(object sender, EventArgs e)
        {
            EventsView eventsView = sender as EventsView;
              
            eventsView.DataBind();
        }

    Thanks
    Venkat.
Register for webinar
18 posts, 0 answered