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

Forums / Developing with Sitefinity / Extending DownloadList and adding thumbnails to documents

Extending DownloadList and adding thumbnails to documents

17 posts, 0 answered
  1. Sam
    Sam avatar
    9 posts
    Registered:
    03 Jan 2011
    04 Jan 2011
    Link to this post
    Hi,
    I'm working on a SiteFinity 3.6 installation and I want to provide the following customisations to a DownloadList control:

    - Allow the user to upload a thumbnail image against documents in the library (and show them on the front view of the website)
    - Limit the documents shown to a specific tag

    I have attempted the first item by adding a new meta field to the web.config (under the <metaFields> section):

    <add key="Libraries.Thumbnail" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue=""/>

    I have then added this meta field to the <libraryInfo> section:

    <add name="Document" title="Document Library" defaultExtenstions=".doc, .docx, .rtf, .txt, .pdf, .ppt, .pptx, .html, .xls, .xlsx" metaKeys="Author, Description, Extension, Name, Size, Category, Thumbnail">

    Then I edited the file in ~/Sitefinity/Admin/ControlTemplates/Libraries/ControlPanelEdit.ascx and added the following within the <sfGCn:ContentMetaFields ID="editMetaFields" runat="server"> section:

    <li>
        <asp:Label ID="Label99" AssociatedControlID="Thumbnail" runat="server" Text="Thumbnail"></asp:Label>
        <asp:TextBox runat="server" ID="Thumbnail"></asp:TextBox>
    </li>

    However it is not showing up in the admin interface.

    Any assistance with both of these items would be greatly appreciated.

    Many thanks,
    Sam
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    04 Jan 2011
    Link to this post
    Hi Sam,

    What do you mean by "it is not showing up in the admin interface" ? Do you have a control that is supposed to display your thumbnail? What string you set as a value of the Text property of the Text box and where you use it?

    To filter DownloadList by tag you can use its FilterExpression property located in the Advanced tab of the control. You can filter only by a single tag using Tag.Name = "yourtag"

    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
  3. Sam
    Sam avatar
    9 posts
    Registered:
    03 Jan 2011
    05 Jan 2011
    Link to this post
    Hi,

    Many thanks for your fast and helpful response.

    With regards to the thumbnail, I thought that modifying the ~/Sitefinity/Admin/ControlTemplates/Libraries/ControlPanelEdit.ascx file would show this field on the admin screen?  I want to see the thumbnail textbox (currently set with an ID="Thumbnail") in the Modules > Images & Documents > Edit Document screen, so that I can upload a thumbnail for each document.

    Then I want to display it on the front end.

    Am I missing something in getting this field to display in the edit document page?

    With regards to filtering by tag, I'll give the FilterExpression a go.

    Kind regards,
    Sam
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    05 Jan 2011
    Link to this post
    Hi Sam,

    ControlPanelEdit.ascx template is no more in used. It is not used since Sitefinity 3.6. In Sitefinity 3.6 you should  map the external template - LibraryItemEdit.ascx  and modify it. You can take a look at our User Manual, page 214 , section Adding Custom Fields.

    You can use ButtonSelector to add reference to an image

    <%@ Register TagPrefix="sfLib" Namespace="Telerik.Libraries.WebControls" Assembly="Telerik.Libraries" %>
     
     
    <asp:TextBoxID="imageUrlTextBox"runat="server">
     
    <sfLib:ButtonSelectorID="sfImageSelector"WindowNavigateUrl="~/Sitefinity/UserControls/Dialogs/ImageDialog.aspx"AssociatedControls="imageUrlTextBox"
    runat="server"ItemTemplatePath="~/Sitefinity/Admin/ControlTemplates/Libraries/Dialogs/ButtonSelector.ascx"/>


    Then you need to resolve the dynamic url

    Kind regards,
    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. Sam
    Sam avatar
    9 posts
    Registered:
    03 Jan 2011
    05 Jan 2011
    Link to this post
    Many thanks Ivan.

    However, I cannot find the file LibraryItemEdit.ascx.  I have tried searching the entire SiteFinity folder structure but to no avail.  Can you advise where I can locate this file?

    Kind regards,
    Sam
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    05 Jan 2011
    Link to this post
    Hi Sam,

    Please take a look a [ExternalTemplatesArchive]Sitefinity\Admin\ControlTemplates\Libraries. You have to download the external templates.

    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. Sam
    Sam avatar
    9 posts
    Registered:
    03 Jan 2011
    05 Jan 2011
    Link to this post
    Hi Ivan,

    OK thank you.  Where can I download the external templates archive?  We have inherited the SiteFinity installation from another web development company and I am not sure if we have their account details in order to access the downloads section.  What can you suggest?

    Many thanks,
    Sam
  8. Sam
    Sam avatar
    9 posts
    Registered:
    03 Jan 2011
    07 Jan 2011
    Link to this post
    Hi there,
    I just wondered if anyone had a chance to look at this?  Any pointers you can give me would be very helpful as I have a client waiting.

    Many thanks,
    Sam
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    07 Jan 2011
    Link to this post
    Hi Sam,

    This post - map the external template explains from where you get the templates.

    Kind regards,
    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
  10. Sam
    Sam avatar
    9 posts
    Registered:
    03 Jan 2011
    07 Jan 2011
    Link to this post
    Hi Ivan,

    Thank you.  However we have inherited the SiteFinity installation from another web development company and we do not have their Client.Net log in details, so we cannot access the download.

    Is there another way for us to access these templates?

    Many thanks,
    Sam
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    07 Jan 2011
    Link to this post
    Hello Sam,

    You can download a trial which will give you access to the external template resources.

    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
  12. Sam
    Sam avatar
    9 posts
    Registered:
    03 Jan 2011
    14 Jan 2011
    Link to this post
    Hi Ivan,

    Many, many thanks for your help.  I have now got the thumbnails working with the button selector.

    Once the user has uploaded their image, is it possible to resize it down?

    Thanks,
    Sam
  13. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    14 Jan 2011
    Link to this post
    Hello Sam,

    You can use the ThumbnailUrl of the IContent - library item. This url gives you access to the generated thumbnail during item upload.

    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
  14. Sam
    Sam avatar
    9 posts
    Registered:
    03 Jan 2011
    21 Jan 2011
    Link to this post
    Hi Ivan,

    Many thanks for your help.  Could you give me some further help as to how to access the IContent interface and the ThumbnailUrl property in code?

    Many thanks,
    Sam
  15. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    21 Jan 2011
    Link to this post
    Hello Sam,

    Please take a look at Finding content items

    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
  16. Sam
    Sam avatar
    9 posts
    Registered:
    03 Jan 2011
    21 Jan 2011
    Link to this post
    Many thanks.

    Is it possible to do this:

    <img sfref="[Libraries]c2324561-bcd4-4978-a63c-ceedb1fe8350" src="/EmptyProject/Images/Desert.sflb.ashx?width=150&height=150" alt="text" />

    As per the post here: http://www.sitefinity.com/devnet/forums/sitefinity-3-x/general-discussions/single-image-thumbnail.aspx

    How do I load the sfref attribute?  Here's the code that I'm using inside the repeater ItemDataBound() event:

        Image thumbImage = e.Item.FindControl("ThumbnailImg") as Image;
        Literal image = e.Item.FindControl("Thumbnail") as Literal;
        if (thumbImage != null && image!=null)
        {
            string item = image.Text;
            //Guid guid = new Guid(item.Substring(item.IndexOf("]") + 1));
            //Telerik.Libraries.LibraryManager manager = new Telerik.Libraries.LibraryManager();
            //Telerik.Cms.Engine.IContent cnt = manager.GetContent(guid);
            //blogImage.ImageUrl = cnt.UrlWithExtension;
    if(image.Text != "")
    {
        thumbImage.ImageUrl = image.Text;
        //thumbImage.ImageUrl = cnt.ThumbnailUrl;
    }
    else
    {
        thumbImage.Visible = false;
    }
        }

    Another problem is that the contents of the "image" variable is simply the URL of the image, not the GUID.  Therefore I cannot use manager.GetContent(guid) at the moment.

    Many thanks,
    Sam
  17. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    21 Jan 2011
    Link to this post
    Hello Sam,

    You have to pass an valid ID of an content item - Image from Images and Documents module. Then you have to return this value inside ItemDataBound method you have pasted and resolve the thumbnail url. This is all you have to do. You can have several predefined images for the equal content types - Iamges, Documents - PDF, Word Document, Power Point etc, which you can distinguish by mime type and assign proper images to them.

    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
Register for webinar
17 posts, 0 answered