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

Forums / Developing with Sitefinity / Inheriting the ImageGallery Control

Inheriting the ImageGallery Control

6 posts, 0 answered
  1. joeldickson
    joeldickson avatar
    9 posts
    Registered:
    12 Feb 2007
    20 Jul 2009
    Link to this post
    Hi,

    I'm trying to create a custom control by Inheriting the ImageGallery Control. To give you a basic form of what i'm doing without getting into the full detail. I am currently trying to pass a parameter via the URL and use it to filter for all Images with certain tag.

    Currently All i'm getting is a table appearing with two cells, one with the text "Title" and the other "Szie". The template ascx file that I am using does not have this HTML in there, its got "nothing" like this. SO not sure what is going one. Any help would be appreciated.

    Thanks in advance,

    Joel

    using System;  
    using System.Data;  
    using System.Configuration;  
    using System.Web;  
    using System.Web.Security;  
    using System.Web.UI;  
    using System.Web.UI.HtmlControls;  
    using System.Web.UI.WebControls;  
    using System.Web.UI.WebControls.WebParts;  
    using Telerik.Cms.Engine;  
    using Telerik.Libraries;  
    using System.ComponentModel;  
    using Telerik.Web; 
    using Telerik.Libraries.WebControls; 
    using System.Data.SqlClient; 
     
    namespace hs 
    /// <summary> 
    /// Summary description for TagViewImage 
    /// </summary> 
    [ToolboxItem(typeof(GalleryToolboxItem))]  
    public class PlayerTagViewImage : Telerik.Libraries.WebControls.ImageGallery 
      
        protected override void CreateChildControls() 
        { 
          
                base.TagItemKey = HttpContext.Current.Request.QueryString["id"]; 
           
            base.LightBoxListTemplatePath = "~/Sitefinity/ControlTemplates/Libraries/GalleryLightboxListSubPage.ascx"
            base.GalleryTemplateMode = GalleryViewMode.Lightbox; 
            base.CreateChildControls(); 
        }  
     
    public class TagViewImageToolboxItem : ToolboxItem 
        public TagViewImageToolboxItem() 
            : base(typeof(PlayerTagViewImage)) 
        { 
            base.DisplayName = "Tag View Photo"
            base.Description = "Displays all of the Photos of a specified Tag."
        } 
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    20 Jul 2009
    Link to this post
    Hi joeldickson,

    The problem is that you are calling the base class instead of overriding layouttemplatePath property. Please take a look at the code below:

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using Telerik.Libraries.WebControls; 
     
    /// <summary> 
    /// Summary description for CustomImageGallery 
    /// </summary> 
    public class CustomImageGallery : ImageGallery 
        public CustomImageGallery() 
        { 
            // 
            // TODO: Add constructor logic here 
            // 
        } 
     
        public override string ItemListTemplatePath 
        { 
            get 
            { 
                return "relative path to your template"
            } 
        } 
     
        public override Type LocalizationAssemblyInfo 
        { 
            get 
            { 
                return typeof(ImageGallery); 
            } 
            set 
            { 
                base.LocalizationAssemblyInfo = value; 
            } 
        } 
     
        protected override void CreateChildControls() 
        { 
            base.CreateChildControls(); 
            this.GalleryTemplateMode = GalleryViewMode.Lightbox; 
            this.BehaviorMode = BehaviorModes.Master; 
        } 
     

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. joeldickson
    joeldickson avatar
    9 posts
    Registered:
    12 Feb 2007
    20 Jul 2009
    Link to this post
    Hi Ivan,

    Thanks for your help. I have tried your source code and am getting the same results.

    Any ideas?

    Thanks,

    Joel
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    21 Jul 2009
    Link to this post
    Hi joeldickson,

    LightBoxListTemplatePath is obsolete and it is no more in use. Override ItemListTemplatePath. When you override ItemListTemplatePath it is not possible to get the same result, because you implicitly set the path in the custom control.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. joeldickson
    joeldickson avatar
    9 posts
    Registered:
    12 Feb 2007
    21 Jul 2009
    Link to this post

    Hi Ivan,

    Thanks for that, I found this post.

    http://www.sitefinity.com/support/forums/sitefinity-3-x/developing-with-sitefinity/problem-with-imagegallery-in-version-3-6.aspx

    I was having this problem as well.

    Now I've hit another wall i need help with.

    I need to programmatically filter this images.

    this.TagItemKey = "test1";

    Inside the create child controls overide. ANd its not filtering at all.

    Should i be using the text name of the tag or the GUID? And do i have to call a method after this to Bind it? am i doing this the right way?

    Thanks in Advance Ivan, ur a Champ.

    Joel

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    21 Jul 2009
    Link to this post
    Hello joeldickson,

    You can override the method below and use ContentFilterBuilder.

        protected override System.Collections.IList CreateDataSource() 
        { 
            var builder = new ContentFilterBuilder(this); 
            builder.AddFilter(new ContentFilterStatement("Tag.Name""test", Telerik.Cms.Engine.ContentViewFiltering.ContentFilter.Condition.Equal));         
            return base.CreateDataSource();  
        } 

    TagItemKey property can be overridden or directly hard coded.

         
       public override string TagItemKey 
        { 
            get 
            { 
                object tagKeyObj = this.ViewState["TagKey"]; 
                if (tagKeyObj == null
                    return LibraryManager.GalleryTagKey; 
                return (string)tagKeyObj; 
            } 
            set 
            { 
                this.ViewState["TagKey"] = value; 
            } 
        } 
     
    .... 
       ... 
     
    protected override System.Collections.IList CreateDataSource() 
        { 
            var builder = new ContentFilterBuilder(this); 
            builder.AddFilter(new ContentFilterStatement("Tag.Name""test", Telerik.Cms.Engine.ContentViewFiltering.ContentFilter.Condition.Equal)); 
            // directly set the property 
            //TagItemKey = "key?"; 
            return base.CreateDataSource(); 
             
        } 


    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
6 posts, 0 answered