More in this section

Forums / Developing with Sitefinity / Image Gallery Social Bookmarks

Image Gallery Social Bookmarks

10 posts, 0 answered
  1. Duncan Evans
    Duncan Evans avatar
    122 posts
    Registered:
    07 Jul 2009
    05 Aug 2009
    Link to this post
    I have enabled this in the advanced tab of the gallery control but they are not showing!

    Any ideas?

    Duncan
  2. Duncan Evans
    Duncan Evans avatar
    122 posts
    Registered:
    07 Jul 2009
    06 Aug 2009
    Link to this post
    Anyone?
  3. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    07 Aug 2009
    Link to this post
    Hello Duncan Evans,

    Thank you for using our services.

    Can you try the following? Go to ~/Sitefinity/ControlTemplates/Libraries/GaleryListViewItem.ascx edit this control template by adding the following block of markup:
    <asp:Repeater ID="Bookmarks" runat="server"
            <HeaderTemplate><ul class="sf_socialBookmarks"></HeaderTemplate> 
            <ItemTemplate> 
                <li> 
                    <asp:HyperLink ID="BookmarkLink" runat="server"
                        <asp:Image ID="BookmarkImage" runat="server" /> 
                    </asp:HyperLink> 
                </li> 
            </ItemTemplate>   
            <FooterTemplate></ul></FooterTemplate> 
        </asp:Repeater>   
         

    If you do not have that file in your Sitefinity project, please download the External Templates file from your Client.Net account.

    After you have edited the template. Go to the Advanced tab of the control designer of your Image Galery control and in the Template Paths provide the path for the edited template (see attached immage).

    This should do the trick. If you have more questions, please feel fre to contact us.

    Kind regards,
    Rado
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  4. Duncan Evans
    Duncan Evans avatar
    122 posts
    Registered:
    07 Jul 2009
    07 Aug 2009
    Link to this post
    Ok so i downloaded the templates
    Modified the GaleryListViewItem.ascx control, here is the code:
    <%@ Control Language="C#" %> 
    <telerik:cssfilelink id="CssFileLink1" filename="" media="screen" runat="server" 
        embeddedfilename="Telerik.Libraries.Resources.ControlTemplates.Frontend.librariesCommonLayout.css" /> 
    <div id="content" runat="server"
        <class="sf_backToPhotos"
            <asp:HyperLink ID="backToList1" runat="server" Text="<%$Resources:Gallery_GoBack %>" /></p
        <p> 
            <asp:HyperLink ID="PreviousItem" runat="server" Text="Previous" CssClass="sf_previousItem" /> 
            <asp:HyperLink ID="NextItem" runat="server" Text="Next" CssClass="sf_nextItem" /> 
        </p> 
        <class="sf_singleImage"
            <asp:Image ID="Img" runat="server" /></p
        <id="TitleWrap" runat="server" class="sf_singleImageCaption"
            <strong> 
                <asp:Literal ID="Title" runat="server" /></strong
        </p> 
        <ul class="sf_singleImageData"
            <li id="AuthorWrap" runat="server"
                <asp:Literal ID="Author" runat="server" /> 
            </li> 
            <li id="UploadDateWrap" runat="server"
                <asp:Literal ID="UploadDate" runat="server" /> 
            </li> 
            <li id="TagWrap" runat="server"
                <asp:Repeater ID="Tags" runat="server"
                    <HeaderTemplate> 
                        <strong> 
                            <asp:Literal ID="Literal1" runat="server" Text="<%$Resources:Gallery_Tags %>" /></strong
                    </HeaderTemplate> 
                    <ItemTemplate> 
                        <asp:HyperLink ID="tagLink" runat="server" /> 
                    </ItemTemplate> 
                </asp:Repeater> 
            </li> 
        </ul> 
        <asp:Repeater ID="Bookmarks" runat="server"
            <HeaderTemplate> 
                <ul class="sf_socialBookmarks"
            </HeaderTemplate> 
            <ItemTemplate> 
                <li> 
                    <asp:HyperLink ID="BookmarkLink" runat="server"
                        <asp:Image ID="BookmarkImage" runat="server" /> 
                    </asp:HyperLink> 
                </li> 
            </ItemTemplate> 
            <FooterTemplate> 
                </ul></FooterTemplate
        </asp:Repeater> 
    </div> 
     

    Went into he admin console and pointed the the SingleitemTemplatePath to ~/Sitefinity/ControlTemplates/Libraries/GaleryListViewItem.ascx

    Nothing...

    Am i missing something?

    Duncan
  5. Duncan Evans
    Duncan Evans avatar
    122 posts
    Registered:
    07 Jul 2009
    07 Aug 2009
    Link to this post
    Is there any way you could provide me with the logic for the "Bookmarks" repeater? I might want to build my own custom control that displays the social bookmarks that i drag onto any page and is independent of the generic content based controls.

    Duncan
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    10 Aug 2009
    Link to this post
    Hi Duncan Evans,

    Thank you for getting back to me.

    Regarding to your fist reply here is how the template looks on my end:
    <%@ Control Language="C#" %> 
    <telerik:CssFileLink ID="CssFileLink1" FileName="" 
     Media="screen" runat="server" EmbeddedFileName="Telerik.Libraries.Resources.ControlTemplates.Frontend.librariesCommonLayout.css"  /> 
    <div ID="content" runat="server"
        <class="sf_backToPhotos"><asp:HyperLink ID="backToList1" runat="server" Text="<%$Resources:Gallery_GoBack %>" /></p
        <p> 
            <asp:HyperLink ID="PreviousItem" runat="server" Text="Previous" CssClass="sf_previousItem" /> 
            <asp:HyperLink ID="NextItem" runat="server" Text="Next" CssClass="sf_nextItem" /> 
        </p> 
        <class="sf_singleImage"><asp:Image ID="Img" runat="server" /></p
        <ID="TitleWrap" runat="server" class="sf_singleImageCaption"
            <strong><asp:Literal ID="Title" runat="server" /></strong
        </p> 
        <ul class="sf_singleImageData"
            <li ID="AuthorWrap" runat="server"
                <asp:Literal ID="Author" runat="server" /> 
            </li> 
            <li ID="UploadDateWrap" runat="server"
                <asp:Literal ID="UploadDate" runat="server" /> 
            </li> 
            <li ID="TagWrap" runat="server">     
                <asp:Repeater ID="Tags" runat="server"
                    <HeaderTemplate> 
                        <strong><asp:Literal ID="Literal1" runat="server" Text="<%$Resources:Gallery_Tags %>" /></strong
                    </HeaderTemplate> 
                    <ItemTemplate> 
                        <asp:HyperLink ID="tagLink" runat="server" /> 
                    </ItemTemplate> 
                </asp:Repeater> 
            </li> 
            <asp:Repeater ID="Bookmarks" runat="server"
            <HeaderTemplate><ul class="sf_socialBookmarks"></HeaderTemplate> 
            <ItemTemplate> 
                <li> 
                    <asp:HyperLink ID="BookmarkLink" runat="server"
                        <asp:Image ID="BookmarkImage" runat="server" /> 
                    </asp:HyperLink> 
                </li> 
            </ItemTemplate>   
            <FooterTemplate></ul></FooterTemplate> 
        </asp:Repeater>   
         
        </ul> 
    </div> 
     

    Basically you do not need to do anything more than what you have done to enable the social bookmarks. Can you add some arbitrary text to the template, just to make sure that it actually loads the custom template? As I see from your first post you have enabled the Social Bookmarks functionality from the control designer of the Image Gallery, can you double check if that property is still true? If you have enabled caching for that page, can you clear the cache (CTRL+F5) and see if changes will load?

    As for your question about the logic of the Social Bookmarks class. Unfortunately we do not provide source code for our controls. However there is a workaround for this. You use .NET Reflector do disassemble the Telerik.Cms.Engine.dll located in the bin folder of your Sitefinity Project. There you should look for the  Telerik.Cms.Engine.WebControls.ContentView+SocialBookmark class and see how it is implemented.

    Regards,
    Rado
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  7. Duncan Evans
    Duncan Evans avatar
    122 posts
    Registered:
    07 Jul 2009
    10 Aug 2009
    Link to this post
    <%@ Control Language="C#" %> 
    <telerik:cssfilelink id="CssFileLink1" filename="" media="screen" runat="server" 
        embeddedfilename="Telerik.Libraries.Resources.ControlTemplates.Frontend.librariesCommonLayout.css" /> 
    <div id="content" runat="server"
        <class="sf_backToPhotos"
            <asp:HyperLink ID="backToList1" runat="server" Text="<%$Resources:Gallery_GoBack %>" /></p
        <p> 
            <asp:HyperLink ID="PreviousItem" runat="server" Text="Previous" CssClass="sf_previousItem" /> 
            <asp:HyperLink ID="NextItem" runat="server" Text="Next" CssClass="sf_nextItem" /> 
        </p> 
        <class="sf_singleImage"
            <asp:Image ID="Img" runat="server" /></p
        <id="TitleWrap" runat="server" class="sf_singleImageCaption"
            <strong> 
                <asp:Literal ID="Title" runat="server" /></strong
        </p> 
        <ul class="sf_singleImageData"
            <li id="AuthorWrap" runat="server"
                <asp:Literal ID="Author" runat="server" /> 
            </li> 
            <li id="UploadDateWrap" runat="server"
                <asp:Literal ID="UploadDate" runat="server" /> 
            </li> 
            <li id="TagWrap" runat="server"
                <asp:Repeater ID="Tags" runat="server"
                    <HeaderTemplate> 
                        <strong> 
                            <asp:Literal ID="Literal1" runat="server" Text="<%$Resources:Gallery_Tags %>" /></strong
                    </HeaderTemplate> 
                    <ItemTemplate> 
                        <asp:HyperLink ID="tagLink" runat="server" /> 
                    </ItemTemplate> 
                </asp:Repeater> 
            </li> 
            <asp:Repeater ID="Bookmarks" runat="server"
                <HeaderTemplate> 
                    <ul class="sf_socialBookmarks"
                </HeaderTemplate> 
                <ItemTemplate> 
                    <li> 
                        <asp:HyperLink ID="BookmarkLink" runat="server"
                            <asp:Image ID="BookmarkImage" runat="server" /> 
                        </asp:HyperLink> 
                    </li> 
                </ItemTemplate> 
                <FooterTemplate> 
                    </ul></FooterTemplate
            </asp:Repeater> 
            test 
        </ul> 
    </div> 
     

    Here is a screen shot of the template being pointed to this file in the admin console.

    The "test" text i have put in there does nto show anywhere... and the social bookmarks do not show either. The page is being cached but i dump the cache both locally on the browser and restart IIS to rest the APP.... Still nothing. And as you can see, "ShowBookmarks" is enabled and the template is being referenced... No bookmarks.

    Duncan
  8. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    10 Aug 2009
    Link to this post
    Hello Duncan Evans,

    Thank you for getting back to me.

    This is very strange. We have not had problems with the single item template path property before. However there is an alternative way for mapping the control template. You should create the following file (if you already do not have it) ~/App_Data/Configuration/Telerik.Sitefinity.Configuration.ControlsConfig.xml from there you can map the image gallery control templates for single items and for item lists like this:
    <?xml version="1.0" encoding="utf-8"?> 
    <controlsConfig> 
      <viewMap> 
        ... 
         <viewSettings hostType="Telerik.Libraries.WebControls.ImageGallery"
          <additionalTemplates> 
            <add key="ItemListTemplatePath" layoutTemplatePath="~/Sitefinity/ControlTemplates/Libraries/GalleryListView.ascx" /> 
            <add key="SingleItemTemplatePath" layoutTemplatePath="~/Sitefinity/ControlTemplates/Libraries/GalleryListViewItem.ascx" /> 
          </additionalTemplates> 
        </viewSettings> 
       </viewMap> 
    </controlsConfig>  

    After you input this in the ControlsConfig file you should restart the website in order for the changes to take effect.

    Kind regards,
    Rado
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  9. Duncan Evans
    Duncan Evans avatar
    122 posts
    Registered:
    07 Jul 2009
    13 Aug 2009
    Link to this post
    If anyone would like a stand-alone control for displaying these social bookmarks on any page anywhere, here is a quick and dirty one i wrote:

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="SocialBookmarks.ascx.cs" 
        Inherits="UserControls_SocialBookmarks" %> 
    <asp:Panel ID="pnlSocialBookmarks" runat="server"
        <div id="socialbookmarks"
            Share this page!<br /> 
            <asp:Repeater ID="Bookmarks" runat="server" OnItemDataBound="Bookmarks_ItemDataBound"
                <ItemTemplate> 
                    <asp:HyperLink ID="BookmarkLink" runat="server"
                        <asp:Image ID="BookmarkImage" runat="server" /> 
                    </asp:HyperLink> 
                </ItemTemplate> 
            </asp:Repeater> 
        </div> 
    </asp:Panel> 
     
    using System; 
    using System.Data; 
    using System.Configuration; 
    using System.Collections; 
    using System.Web; 
    using System.Web.Security; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using System.Web.UI.WebControls.WebParts; 
    using System.Web.UI.HtmlControls; 
    using System.Collections.Specialized; 
    using System.ComponentModel; 
     
    using System.Xml; 
    using System.Text; 
    using System.IO; 
     
    using Telerik.Cms; 
    using Telerik.Cms.Web; 
    using Telerik.Web.UI; 
    using Telerik.Cms.Web.UI; 
     
    public partial class UserControls_SocialBookmarks : System.Web.UI.UserControl 
        XmlDocument BookmarkTemplateXml = new XmlDocument(); 
        string PageTitle; 
        string PageUrl; 
        #region Control Properties 
     
        [Category("Settings"), WebEditor("Telerik.FileManager.UrlWebEditor, Telerik.FileManager")] 
        public virtual string SocialBookmarkTemplate 
        { 
            get 
            { 
                object obj = this.ViewState["SocialBookmarkTemplate"]; 
                if (obj != null
                { 
                    return Convert.ToString(obj); 
                } 
                return ""//~/Sitefinity/ControlTemplates/Blogs/socialBookmarkTemplate.xml 
            } 
            set 
            { 
                this.ViewState["SocialBookmarkTemplate"] = value; 
            } 
        } 
     
        [Category("Settings"), Description("")] 
        public virtual string SocialBookmarkImageFolder 
        { 
            get 
            { 
                object obj = this.ViewState["SocialBookmarkImageFolder"]; 
                if (obj != null
                { 
                    return Convert.ToString(obj); 
                } 
                return "~/Sitefinity/ControlTemplates/Blogs/SocialBookmark/"
            } 
            set 
            { 
                this.ViewState["SocialBookmarkImageFolder"] = value; 
            } 
        } 
        #endregion 
     
        protected void Page_Load(object sender, EventArgs e) 
        { 
            if (!Page.IsPostBack) 
            { 
                try 
                { 
     
                    string BookmarkTemplatePath = base.Server.MapPath(SocialBookmarkTemplate); 
     
                    if (BookmarkTemplatePath != ""
                    { 
                        StreamReader BookmarkTemplateStream = new StreamReader(BookmarkTemplatePath); 
                        BookmarkTemplateXml.LoadXml(BookmarkTemplateStream.ReadToEnd()); 
                        BookmarkTemplateStream.Close(); 
     
                        ICmsUrlContext context = CmsUrlContext.Current; 
                        CmsManager cmsManager = new CmsManager(); 
                        ICmsPage CurrentCMSPage = ((Telerik.Cms.ICmsPage)cmsManager.GetPage(context.PageID, false)); 
     
                        PageTitle = CurrentCMSPage.Title; 
                        PageUrl = GetURL(CurrentCMSPage.StaticUrl); 
     
                        Bookmarks_DataBind(); 
                    } 
                    else 
                    { 
                        pnlSocialBookmarks.Visible = false
                        return
                    } 
                } 
                catch (Exception ex) 
                { 
                    pnlSocialBookmarks.Visible = false
                    return
                } 
            } 
        } 
     
        public void Bookmarks_DataBind() 
        { 
            XmlNodeList BookmarkTemplateNodes = BookmarkTemplateXml.SelectNodes("bookmarks/itemTemplate/bookmark"); 
            Bookmarks.DataSource = BookmarkTemplateNodes; 
            Bookmarks.DataBind(); 
        } 
     
        protected void Bookmarks_ItemDataBound(object sender, RepeaterItemEventArgs e) 
        { 
            XmlNode BookmarkTemplateNode = ((XmlNode)e.Item.DataItem); 
     
            RepeaterItem rpi = e.Item; 
            switch (rpi.ItemType) 
            { 
                case ListItemType.Item: 
                case ListItemType.AlternatingItem: 
                case ListItemType.SelectedItem: 
                    { 
                        HyperLink BookmarkLink = e.Item.FindControl("BookmarkLink"as HyperLink; 
                        if (BookmarkLink != null
                        { 
                            StringBuilder socialSiteUrl = new StringBuilder(); 
                            socialSiteUrl.AppendFormat(BookmarkTemplateNode.SelectSingleNode("url").InnerText, PageUrl, PageTitle); 
                            BookmarkLink.NavigateUrl = socialSiteUrl.ToString(); 
                            BookmarkLink.Target = "_blank"
                        } 
     
                        XmlNode extendedPropertyNode = BookmarkTemplateXml.SelectSingleNode("bookmarks/extendedProperty/image"); 
                        string ImageSize = extendedPropertyNode.SelectSingleNode("size").InnerText; 
                        string ImageType = extendedPropertyNode.SelectSingleNode("extension").InnerText; 
     
                        string ImageName = BookmarkTemplateNode.Attributes["name"].Value + "_" + ImageSize + "." + ImageType; 
     
                        Image BookmarkImage = e.Item.FindControl("BookmarkImage"as Image; 
                        if (BookmarkImage != null
                        { 
                            BookmarkImage.ImageUrl = SocialBookmarkImageFolder + ImageName; 
                        } 
                    } 
                    break
            } 
        } 
     
        private string GetURL(string url) 
        { 
            try 
            { 
                NameValueCollection vars = HttpContext.Current.Request.ServerVariables; 
                string port = vars["SERVER_PORT"]; 
                string protocol = vars["SERVER_PORT_SECURE"]; 
                System.Web.UI.Control urlResolver = new System.Web.UI.Control(); 
     
                if ((port == null | port == "80" | port == "443")) 
                { 
                    port = ""
                } 
                else 
                { 
                    port = ":" + port; 
                } 
     
                if ((protocol == null | protocol == "0")) 
                { 
                    protocol = "http://"
                } 
                else 
                { 
                    protocol = "https://"
                } 
     
                return protocol + vars["SERVER_NAME"].ToString() + port + ResolveUrl(url); 
            } 
            catch 
            { 
                return string.Empty; 
            } 
        } 
     

  10. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    14 Aug 2009
    Link to this post
    Hello Duncan Evans,

    Thank you for submitting your control. You could also submit it to in our Code Library - we will appreciate it!

    Sincerely yours,
    Rado
    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
10 posts, 0 answered