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

Forums / Developing with Sitefinity / Edit Gallery ListView template

Edit Gallery ListView template

2 posts, 0 answered
  1. Sean
    Sean avatar
    7 posts
    Registered:
    31 Oct 2008
    23 Jul 2009
    Link to this post
    I need to replace the image in the gallery listview template below

     

    <dd class="sf_image"><asp:HyperLink ID="DownloadLink" runat="server" /></dd>

     

    with a regular image container nested in a link so we can click on the image and navitgate to a url instead of a larger view.
    I have a referenced external template that I copied from the original that I'm making alterations to.
    I have the url "ImageLink" set up as a metafield in the libarary and can access it no problem in the view. I just don't know how to get to the image. I tried to replace the asp:Hyperlink tag with an asp:image tag and that didn't work.

    Goal is to have this:

     

     

    <a href="Metafield url value here">

     

     

     

     

     

     

        <asp:Image    Image from gallery here />

     

     

     

     

     

     

    </a>

    Any suggestions on how to make this happen in a custom template or do I need to create a user control for this?

    Thanks,
    Sean

     

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    24 Jul 2009
    Link to this post
    Hi Sean,

    To replace the Hyperlink control with image you need to override ImageGallery control's SetListMetaData method. Below is a sample code:

        protected override void SetListMetadata(System.Web.UI.Control itemContainer, Telerik.Cms.Engine.IContent contentItem) 
        { 
            base.SetListMetadata(itemContainer, contentItem); 
            var img = itemContainer.FindControl("DownloadLink"as System.Web.UI.WebControls.Image; 
            if (img != null
            { 
                string url = contentItem.Url + this.Manager.Provider.ThumbnailExtension; 
     
                if (this.ThumbnailMaxSize > 0) 
                { 
                    url += "?width=" + this.ThumbnailMaxSize.ToString() + 
                           "&height=" + this.ThumbnailMaxSize.ToString() + 
                           "&decreaseOnly=true&proportional=true"
                } 
                img.ImageUrl = ResolveUrl(url); 
            } 
     
        } 


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