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

Forums / Developing with Sitefinity / Question about custom image gallery

Question about custom image gallery

2 posts, 0 answered
  1. Chad
    Chad avatar
    1 posts
    Registered:
    23 Jul 2010
    02 Sep 2010
    Link to this post
    Hi.

    New to sitefinity.  I've made a slideshow (custom user control) for displaying an image library, and I'd like to make it easier for my users to add the slideshow and not have to configure anything but what gallery to load.

    My goal is to:  use the standard image gallery module (I don't want to reinvent the wheel), but add a description metafield, force the usercontrol to limit the number of images to 50, force the "simple list" view mode, and set the default template to be my user control.

    Because image gallery doesn't have a description field, I used the method of adding the metafield to a copy of the image gallery in the web.config file.

    <add name="S_Slideshow" title="S_Slideshow" defaultExtenstions=".png, .jpg, .jpeg, .gif" metaKeys="Description, Author, AlternateText, Extension, Name, Height, Width, Size, Category">
            </add>

    I then created an ProductSlideshow.cs class in the AppData folder, and set the toolbox control to that type, like so...

    <add name="SlideshowView" section="Products Slideshow" type="ProductSlideshow, App_Code" description="Slideshow viewer for Products" />

    ProductSlideshow.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
     
    /// <summary>
    /// Summary description for ProductSlideshow
    /// </summary>
    public class ProductSlideshow : Telerik.Libraries.WebControls.ImageGallery
    {
        public ProductSlideshow()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        public override string ProviderName
        {
            get
            {
                return "Libraries";
            }
        }
     
        public override string ItemListTemplatePath
        {
            get
            {
                return "~/UserControls/S_Slideshow/GallerySimpleList.ascx";
            }
        }
        public override int ItemsPerPage {
            get
            {
                return 50;
            }
        }
    }


    So, when I add my slideshow control to a page, I can see in the editor that my custom user control is being used, it's putting the 50 in the items per page advanced setting.  However, I *only* see "Image Galleries" now...I no longer see the Slideshow gallery that I setup (so that I could have a description).  I can't figure out how to set this library so that the Slideshow galleries are displayed in the edit control.

    As for the simple list mode, I'm *guessing* from the API reference documentation that I need to override the "presentationmode", but I don't know what value/type/etc to set in the override method.

    So, I have two questions if anyone wouldn't mind lending me a hand.  1, What provider should I be using here?  and 2. How do I set the default display to be simple list?

    Also, if I'm going about this the wrong way, feel free to criticize  - I'm new to this and have thick skin :)

    Thanks!
    Chad
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    02 Sep 2010
    Link to this post
    Hello Chad,

    Dynamic fileds are valid only for IContent items. Libraries (ILibrary) cannot use dynamic fields out of the box. By default ImageGallerycontrol from which you are inheriting from shows only galieries of type Image.

    You can create an image library and set the metakey for your items, then filter the entire list by using FilterExpression property of ImageGallery control or ContentFilterBuilder  inside CreateChildControls before calling the base.

    1. What provider should I be using here?

    The defaul provider is "Lirabraries". You have to us this provider under you have created your library

    2. How do I set the default display to be simple list?

    sample code

    protected override void CreateChildControls()
       {
     
           galleryViewMode = GalleryViewMode.Simple;
           base.CreateChildControls();
            
       }
     
    private ImageGallery.GalleryViewMode galleryViewMode = GalleryViewMode.ListDetails;


    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
2 posts, 0 answered