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

Forums / Suggestions / Download widget template improvements

Download widget template improvements

16 posts, 0 answered
  1. Markus
    Markus avatar
    2763 posts
    Registered:
    25 Nov 2005
    07 Dec 2012
    Link to this post
    Good day

    It would be nice if I could define my own extra download templates like other templates as well. It seems there is no option yet to choose/create another.

    Also the size for small documents is shown like 27,91 KB kilo bytes. I a time where we need 500 MB to run SF and a braoad band internet connection for all our content I think it would be enough to show  27 KB instead of 27,91 KB

    See screenshot.

    Markus
  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    22 Sep 2016
    12 Dec 2012
    Link to this post
    Hi Markus,

    Yes there is no option to create new widget template and add it to the list of download list templates out of the box. I have logged the feature request, here is the link to pits.

    For the bytes calculation create new template using the template for documents table (I have attached it here). Map the template to be used instead of the built in template by going to Administration->Settings->Advanced->ContentView->controls->Create new

    Host: Telerik.Sitefinity.Modules.Libraries.Web.UI.Documents.MasterTableView
    LayoutTemplate: ~/DocumentsTableView.ascx (relative path to the template in your project)
    save changes and restart the project to use the mapped template.

    In the code behind of the template I have subscribed to the databinding event of the grid that makes up the table of documents to download
    void  documentsGrid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
            {
                if ((e.Item.ItemType == GridItemType.Item) || (e.Item.ItemType == GridItemType.AlternatingItem))
                {
                    var dataItem = e.Item.DataItem;
                    var gridItem = e.Item as GridDataItem;
                    var document = (Document)dataItem;
                    if (document != null)
                    {
                        var ext = document.Extension;
                        if (ext.Length > 0)
                            ext = ext.Remove(0, 1);
     
                        gridItem.CssClass += " sf" + ext.ToLower();
                        TableCell typeCell = gridItem["documentType"];
                        if (typeCell != null)
                            typeCell.Text = ext.ToUpperInvariant();
                        TableCell totalSizeCell = gridItem["totalSize"];
                        if (totalSizeCell != null)
                            //here is the binding of bytes
                            totalSizeCell.Text = this.ConfigureBytes(document.TotalSize);
     
                        var documentLink = e.Item.FindControl("documentLink") as HyperLink;
                        if (documentLink != null)
                            documentLink.NavigateUrl = document.MediaUrl;
                    }
                }
            }
    The highlighted line shows the method to calculate the bytes of the document. I have also added it in the code behind for modifications

    All the best,
    Stanislav Velikov
    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. Markus
    Markus avatar
    2763 posts
    Registered:
    25 Nov 2005
    12 Dec 2012 in reply to Stanislav Velikov
    Link to this post
    Dear Stanislav

    Thanks for opening a PITS on this. I first proposed this in May 2011! Yes 1 1/2 years ago. http://www.sitefinity.com/developer-network/forums/bugs-issues-/download-link-download-list-dokuments-and-files

    Steves post from Februar 2011! http://www.sitefinity.com/developer-network/forums/bugs-issues-/download-list-templates
    I hope it does not take that long to implement some consistency here. Why can I choose templates on so many widgets but not on decument list is a secret to me.

    -----------

    About the KB download. Thank you for providing the solution. I don't feel like having to do this in every new project. I simply wished that Telerik would see that it does not make sense to show 24.79 KB and would change it so that out of the box you get 24,5 MB or if smaller 399 KB. 
    This would I guess help anyone here.

    -----------

    Markus

  4. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    14 Dec 2012 in reply to Markus
    Link to this post
    Yeah, no pickable templating has been a big pet peeve of mine since "RELEASE".  I think it was one of the first controls likely created when they didn't have that functionality yet, and nobody has ever gone back to update the designer to support it.

    (Just a guess)
  5. Markus
    Markus avatar
    2763 posts
    Registered:
    25 Nov 2005
    16 Oct 2013 in reply to Steve
    Link to this post
    Allmost a year later and I still miss the option to choose from different layoutwidget.

    Markus

    Also in Gallery
  6. Markus
    Markus avatar
    2763 posts
    Registered:
    25 Nov 2005
    06 Nov 2013 in reply to Markus
    Link to this post
    Dear Stanislav

    Thanks for your solution from April 2013 but I don't want to extend SF on every new project to get some sense into the download widget.

    a) 6.2 still not lets you choose different templates 
    b) I still think it would be nice if someone at Telerik found some time to fix the way size is displayed.  See screenshot. 

    - I know its not a big deal
    - I know I can work around it

    But do my clients care if a document is 156 KB or 156,06 KB

    Markus
  7. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    22 Sep 2016
    11 Nov 2013
    Link to this post
    Hello Markus,

    The ability to select different templates have to be added to download list widget designer as new feature for the widget. Refer to the workaround and if you have need for another customization on the widget please let me know.

    Regards,
    Stanislav Velikov
    Telerik
    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
  8. Markus
    Markus avatar
    2763 posts
    Registered:
    25 Nov 2005
    11 Nov 2013 in reply to Stanislav Velikov
    Link to this post
    Dear Stanislav

    Do I read you correctly? Telerik is not going to add the option to use different download templates and we have to do it ourself?

    Markus
  9. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    11 Nov 2013 in reply to Markus
    Link to this post
    @Markus
      I'll put money it's not fixed for 6.3....JustDecompile the widget and you can pretty much see why...

    Other controls like the nav widget have their "Modes" but each "Mode" is just a new template (shapes the markup differently).  The Download widget though seems to be pretty gimpy in the way it was designed.

    Have a look at "Telerik.Sitefinity.Resources.Templates.Frontend.Libraries.Documents.MasterListView.ascx"...it's a repeater who's data is set IN THE CODE BEHIND instead of Eval statements in the markup for you to change....so even if you could change the markup in a new template you don't have the control you would want.

    ...the widget needs a re-write...not just a template picker.  I shudder at this thought after twitter was given to someone to rewrite (more than once) and the end result was terrible both times, like no oversight...it's STILL terrible (who makes a client-side twitter widget when the data is pulled from SF publishing not twitter).

    Steve
  10. Markus
    Markus avatar
    2763 posts
    Registered:
    25 Nov 2005
    12 Nov 2013
    Link to this post
    @Steve

    This might be the reason for the do-it-yourself -> we are not going to do it answer from Stanislav (unless I did missread it totaly)

    Markus
  11. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    22 Sep 2016
    14 Nov 2013
    Link to this post
    Hi,

     The markup of download list template and most of the templates for sitefintiy widgets have the datasource toward which the template is bound available in a class outside of the widget template, based on this the provided approach to subscribe to documentsGrid_ItemDataBound event is the way to handle customization on this template.
    I can provide you with another approaches for having control over the whole class includes the download list implementation where additional functionality/modifications can be injected to server certain business case.

    Regards,
    Stanislav Velikov
    Telerik
    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
  12. Markus
    Markus avatar
    2763 posts
    Registered:
    25 Nov 2005
    14 Nov 2013 in reply to Stanislav Velikov
    Link to this post
    Dear Stanislav

    Thanks for the option of an another approach and again thanks for the code for the workaround.

    Acutally I would prefer Telerik simply doing this for every single Sitefinity user in the world and like on other widgets give as the option to choose. Well we can make different download widget in the designer just choosing them is a pain in the neck - And for every project must be done again.

    I assume that I have not missread all the comments and we will not get the option to choose different widgets on the download template anytime soon - or anytime.

    Markus

    PS: But I am sure 6.3 will bring a lot of other new features we can be looking for. Guess you can close this thread :-(
  13. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    14 Nov 2013 in reply to Markus
    Link to this post
    @Markus I'm with you 100% on this...Stanislav doesn't understand the problem.

    We're not looking to extend functionality, we're looking to do what we can do with 98% of the other widgets...change and create new templates.  Without this functionality you're telling us we have to use the same markup for EVERY download widget across the entire site...which is crazy.

    Steve
  14. Markus
    Markus avatar
    2763 posts
    Registered:
    25 Nov 2005
    04 Jul 2014 in reply to Steve
    Link to this post

    Sorry to bring this up again.

    But now I have a project where I am in the need of having two templates. 

    After 3 years it is still not possible. You can create different widget templates but use only the default. Unless I am missing something again.

    Even modules created with module builder let you choose templates: www.marktold.com/screencast/sf_7_0_tempaltes.swf 

    Markus

     PS: @Steve you were right about 6.3 :-)

     

  15. Pavel Benov
    Pavel Benov avatar
    341 posts
    Registered:
    14 Mar 2016
    09 Jul 2014
    Link to this post
    Hi Markus,

    Since the desired implementation is not yet available out of the box a custom solution should be used if you require the control to be able to display different templates throughout the project. The below example uses the List type for simplicity's sake, but this can be implemented for the other view types the controls uses (Table, List+Detail page, Table+Detail page). 

    The List view type uses MasterListView control. By inheriting from this control and overriding the LayoutTemplatePath property you can conditionally pass different templates to the view like so:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Sitefinity.Modules.Libraries.Web.UI.Documents;
     
    namespace SitefinityWebApp
    {
        public class CustomMasterListView : MasterListView
        {
            public override string LayoutTemplatePath
            {
                get
                {
                    if (SiteMap.CurrentNode.Title == "Test") //Define whatever criteria you find suitable
                    {
                        return "~/CustomDownloadListTemplate.ascx";
                    }
                    else
                    {
                        return base.LayoutTemplatePath;
                    }
                }
                set
                {
                    base.LayoutTemplatePath = value;
                }
            }
        }
    }

    Where CustomDownloadListTemplate.ascx is a custom template in my solution. To be able to use more than 2 templates you could use a switch and depending on the criteria, return a different template. 

    To register this view you can go to Advanced settings->ContentView->Controls->FrontendDocuments->Views->MasteListView and provide the custom view's type in the ViewType field. Save and recycle the application for the changes to take effect and you should now be able to load 2+ templates through the control. 

    Regards,
    Pavel Benov
    Telerik
     
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  16. Markus
    Markus avatar
    2763 posts
    Registered:
    25 Nov 2005
    09 Jul 2014 in reply to Pavel Benov
    Link to this post

    Thanks Pavel for the work around.

    Somehow I have the feeling is not quit es flexibel :-)

    Markus

16 posts, 0 answered