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

Forums / Developing with Sitefinity / Widget code-behind for single item templates

Widget code-behind for single item templates

2 posts, 0 answered
  1. David Rhodes
    David Rhodes avatar
    42 posts
    Registered:
    24 May 2005
    27 Mar 2014
    Link to this post

    Hi,

    I've been using the following to add code-behind to built in widgets for list items which works great 

    http://www.sitefinity.com/developer-network/forums/developing-with-sitefinity-/howto-guide-add-code-behind-to-a-sitefinity-widget-template

    I'd like to do the same for single items, does anyone know how I can access the data items in the code-behind? 

  2. Junior Dominguez
    Junior Dominguez avatar
    115 posts
    Registered:
    02 Dec 2016
    01 Apr 2014
    Link to this post
    Hi David,

    The procedure would be similar for a single item, but in this case you will work on the Full Blog Post item template by going to Design>>Widget  Templates.

    Another easy way to get the current item would consist on extending the Blog Posts widget (or creating a new one). It is easily possible by creating a class which inherits from BlogPostView in Visual Studio as shown on this video.

    The code may look similar to this:

    public class CustomBlogPostItem : BlogPostView
        {
            protected override void CreateChildControls()
            {
                base.CreateChildControls();
                var view = this.CurrentView;
                if (view.ViewType.FullName == "Telerik.Sitefinity.Modules.Blogs.Web.UI.Public.DetailPostView")
                {
                    var item = this.DetailItem;
     
     
                }
     
            }
        }



    Kind Regards,
    Junior Dominguez
    Telerik
     
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
2 posts, 0 answered