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

Forums / Designing with Sitefinity / customise image library

customise image library

7 posts, 0 answered
  1. sathiyaseelan
    sathiyaseelan avatar
    82 posts
    Registered:
    26 Aug 2008
    27 Jul 2010
    Link to this post
    Hi sir,

    I need to develop a image gallery listing in my site.I had put the sitefinity image gallery control but that shows the images in the library by default.

    I want to show the library list first and secondly on clicking the particular list the images added to it need to show in list and on further clicking it that image needs to open in a light box.

    can this be achieved with in sitefinity default control or i need to built a new custom control for this.

    Pls help me on this,

    Thanks
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    27 Jul 2010
    Link to this post
    Hello sathiyaseelan,

    You need to create a custom control with two nested repeaters - the first repeater will show library names, since the second one will show items for a given library. The default control does not support this behavior out of the box.

    sample code

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Cms.Web.UI;
    using System.Web.UI.WebControls;
    using System.Collections;
    using Telerik.Cms.Engine;
      
    /// <summary>
    /// Summary description for ImageGalleryCustom 
    /// </summary>
    public class ImageGalleryCustom  : SimpleControl
    {
        public ImageGalleryCustom ()
        {
        }
      
        public override string LayoutTemplatePath
        {
            get
            {
                return "~/CustomControls/ImageGalleryCustom.ascx";
            }
            set
            {
                base.LayoutTemplatePath = value;
            }
        }
      
        protected override void InitializeControls(System.Web.UI.Control controlContainer)
        {
            base.InitializeControls(controlContainer);
      
            if (MainRepeater != null)
            {
                MainRepeater.DataSource = GetLibrariesDataSource();
                MainRepeater.ItemDataBound += new RepeaterItemEventHandler(MainRepeater_ItemDataBound);
                MainRepeater.DataBind();
            }
        }
      
        void MainRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var c = e.Item.DataItem as ILibrary;
      
                HyperLink libraryLink = e.Item.FindControl("contentLibrary") as HyperLink;
                if (libraryLink != null)
                {
                    libraryLink .Text = c.LibraryName;
                }
                Repeater nesterRepeater = e.Item.FindControl("itemsRepeater") as Repeater;
                if (nesterRepeater != null)
                {
                    nesterRepeater.DataSource = GetContentDataSource("here pass the library name as parameter);
                    nesterRepeater.ItemDataBound += new RepeaterItemEventHandler(nesterRepeater_ItemDataBound);
                    nesterRepeater.DataBind();
                }
            }
        }
      
        void nesterRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
               var cntItem =  e.Item.DataItem as IContent;
      
               HyperLink link =  e.Item.FindControl("contentTitle") as HyperLink;
               if (link != null)
               {
                   link.Text = (string)cntItem.GetMetaData("Name");
                   link.NavigateUrl = cntItem.UrlWithExtension;
               }
            }
        }
      
        protected virtual Repeater MainRepeater
        {
            get
            {
                return this.Container.GetControl<Repeater>("LibrariesRepeater", true);
            }
        }
      
        private IList GetContentDataSource(string LibraryName)
        {
            var cntManager = new ContentManager("Generic_Content");
            List<Telerik.Cms.Engine.IMetaSearchInfo> filter = new List<Telerik.Cms.Engine.IMetaSearchInfo>();
              
           // filter by LibraryName /ParentID
        }
      
        private IList<ICategory> GetLibrariesDataSource()
        {
          // GetAllLibraries
        }
     
      
    }


    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ContentViewSortedByRoleTemplate.ascx.cs" Inherits="CustomControls_ContentViewSortedByRoleTemplate" %>
      
      
      
    <asp:Repeater runat="server" ID="categoryRepeater">
        <ItemTemplate>
          <asp:Repeater runat="server" ID="LibrariesRepeater">
              <ItemTemplate>
               <asp:HyperLink runat="server" ID="contentTitle"></asp:HyperLink>
              </ItemTemplate>
            </asp:Repeater>
        </ItemTemplate>
    </asp:Repeater>


    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. sathiyaseelan
    sathiyaseelan avatar
    82 posts
    Registered:
    26 Aug 2008
    28 Jul 2010
    Link to this post
    Hi sir,

    Is it i need to put the code in user control and call it in sitefinity. If not tell me how do I do this step by step.

    Thanks,
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    28 Jul 2010
    Link to this post
    Hello sathiyaseelan,

    This is a custom control, not a user control. You need to put it in App_Code folder or compile it to a dll. Then you have to register the control inside <toolboxControls> section of your web.config file

    below is the format that you need to use.

    <add name="ControlName" section="SectionName" type="Namespace, AsemblyName" />


    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
  5. sathiyaseelan
    sathiyaseelan avatar
    82 posts
    Registered:
    26 Aug 2008
    28 Jul 2010
    Link to this post
    Thanks i created a custom control ImageGalleryCustom.cs under App_Code and placed the first piece of code .

    Now where I need to place the second piece of code.

    what this line indicates : return
    "~/CustomControls/ImageGalleryCustom.ascx";
    ????

    And also what I need to do here "// filter by LibraryName /ParentID"

    As I am new to this pls help me...

    Thanks,
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    28 Jul 2010
    Link to this post
    Hello sathiyaseelan,

    1. return "~/CustomControls/ImageGalleryCustom.ascx" indicates the path to the control template

    2.For filtering content items,  please take a look at Overview of Generic Content API

    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
  7. sathiyaseelan
    sathiyaseelan avatar
    82 posts
    Registered:
    26 Aug 2008
    28 Jul 2010
    Link to this post
    Thanks Ivan,

    Is it the control template I need to create if yes where I need to create it.

    Also where do i place the following code.

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ContentViewSortedByRoleTemplate.ascx.cs" Inherits="CustomControls_ContentViewSortedByRoleTemplate" %>
      
      
      
    <asp:Repeater runat="server" ID="categoryRepeater">
        <ItemTemplate>
          <asp:Repeater runat="server" ID="LibrariesRepeater">
              <ItemTemplate>
               <asp:HyperLink runat="server" ID="contentTitle"></asp:HyperLink>
              </ItemTemplate>
            </asp:Repeater>
        </ItemTemplate>
    </asp:Repeater>

    Is it I need to create a user control(IContentViewSortedByRoleTemplate.ascx) and place it the above code.

    Thanks a lot,
Register for webinar
7 posts, 0 answered