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

Forums / Developing with Sitefinity / ImageGallery: New GalleryViewMode

ImageGallery: New GalleryViewMode

4 posts, 0 answered
  1. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    06 Jun 2011
    Link to this post

    Hi,

    I've created a new ImageGallery that inherits from the OOTB one.  I've been able to get the control designer set up so I can add a new GalleryViewMode like:
    <sf:PresentationMode ID="RotatorList" 
                         runat="server"
                         ModeTitle="Rotating list"
                         ModeSettingsId="ModeSettings6"
                         MasterTemplatePath="~/Sitefinity/Admin/ControlTemplates/Libraries/Modes/GalleryRotatorList.ascx"
                         SelectedCssClass="selectedOption">
        <Template>
            <asp:RadioButton ID="rotatorListRadio" runat="server" />
            <p><asp:Literal ID="Literal4" runat="server" Text="<%$Resources:GalleryDesigner_RotatorList %>" /></p>
        </Template>
    </sf:PresentationMode>

    This works great. 

    So next I added the public control in my App_Code, inheriting from ImageGallery

    public class CustomImageGallery : ImageGallery
    {

    But now I need to add the new mode "RotatorList" to the GalleryViewMode enum, so that in my public control I can do something like:

    protected override void SetListMetadata(System.Web.UI.Control itemContainer, Telerik.Cms.Engine.IContent contentItem)
    {
        base.SetListMetadata(itemContainer, contentItem);
        switch (this.galleryViewMode)
        {
            case GalleryViewMode.RotatorList:
                HyperLink downloadLink = itemContainer.FindControl("DownloadLink") as HyperLink;
                string navigateUrl = contentItem.GetMetaData("Website") as string;
                if (downloadLink != null && !string.IsNullOrEmpty(navigateUrl))
                {
                    downloadLink.NavigateUrl = navigateUrl;
                    downloadLink.ImageUrl = base.GetItemUrl(contentItem, null);
                }
        }


    So, how do I add my new presentation mode to the GalleryViewMode Enum?  If I try to add an enum to my public control, like this:

    public enum GalleryViewMode
    {
                Simple,
                SimpleOnePerPage,
                ListDetails,
                Lightbox,
                BigImageAndList,
                RotatorList
    }
            
    [...]
      
    switch (base.GalleryTemplateMode)
    {
        case GalleryViewMode.RotatorList:


     I get an error:

    Compiler Error Message: CS0266: Cannot implicitly convert type CustomImageGallery.GalleryViewMode' to 'Telerik.Libraries.WebControls.ImageGallery.GalleryViewMode'. An explicit conversion exists (are you missing a cast?)

    because, of course, my enum isn't the Telerik one.  I'm missing something basic here.  :)

    Thanks,
    Mike


  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    06 Jun 2011
    Link to this post
    Hi Mike,

    You cannot add your custom view to the GalleryViewMode. You need a new enum or check if non of the default types is selected( this will work with one custom view)

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    06 Jun 2011
    Link to this post
    Thanks Ivan,

    I guess for now I'll do the "none of the above" check.  I guess adding an enumerator would be a fair amount of work, since I'd have to connect it to the control designer too.

    One other question on this.  I was planning on using a RadRotator for this image gallery, but it seems like the ImageGallery control expects a Repeater control with an ID of "repeater":

    A required control was not found in the template for "~/Sitefinity/Admin/ControlTemplates/Libraries/Modes/GalleryRotatorList.ascx". The control must be assignable form type "System.Web.UI.WebControls.Repeater" and must have ID "repeater".

    Is there a way to override this?  If not, how would I hook up the RadRotator to an ImageGallery?


    Thanks again!
    Mike
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    09 Jun 2011
    Link to this post
    Hi Mike,

    All content view controls expects Repeater control which is a required control. You can just add it to the template and don't use it with this mode, so you will mimic something like conditional template.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
4 posts, 0 answered