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

Forums / General Discussions / Document Uploader

Document Uploader

7 posts, 0 answered
  1. homepagedigital
    homepagedigital avatar
    13 posts
    Registered:
    06 Jul 2009
    12 Oct 2009
    Link to this post
    Re :http://www.sitefinity.com/support/kb/sitefinity-3-x/how-to-map-a-view-to-an-external-template-in-sitefinity-3-6-or-later.aspx

    For attaching PDF's to news items, the textbox method is not a good solution for the reasons stated. So I am looking to create a custom control as suggested.

    Are there any code samples for reference (quote : making sure it implements the ITextControl interface).

    I am new to telerik and the world of RAD controls so any help greatly appreciated.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    12 Oct 2009
    Link to this post
    Hi Jo Kendal,

    You can crate a new metakey with reference to your PDF that is located under Images and Documents module. You can use Fime Manager Selector or ButtonSelector to navigate to the libraries. Then you can resolve the dynamic link and show it on the front end so everybody will be able to download the PDF.

    Let us know if there is anything else that we can do for you.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. homepagedigital
    homepagedigital avatar
    13 posts
    Registered:
    06 Jul 2009
    12 Oct 2009
    Link to this post
    Thanks for the prompt response.

    OK - we are going to look at this with a view to creating a multi uploader allowing document titling too.
    If successful we will post in full.

  4. homepagedigital
    homepagedigital avatar
    13 posts
    Registered:
    06 Jul 2009
    13 Oct 2009
    Link to this post
    We have completed the admin areas - they work fine with the button selector.

    On the front end we are having issues editing the control template using the following code (adapted to take in the full internal [provider]guid string in our version.

    public string GetItemUrl(string provider, Guid id, bool resolveAsAbsoluteUrl) 
        if (ContentManager.Providers.ContainsKey(provider)) 
        { 
            IContent cnt = ContentManager.Providers[provider].GetContent(id); 
            if (cnt != null
                return VirtualPathUtility.ToAbsolute(cnt.UrlWithExtension, this.Context.Request.ApplicationPath); 
        } 
        else 
        { 
            // we assume it is a page 
            SiteMapNode node = SiteMap.Provider.FindSiteMapNodeFromKey(id.ToString()); 
            if (node != null
                return this.ResolveClientUrl(node.Url); 
        } 
        return String.Concat("Item not found: [", provider, "]", id); 

    When we call the function the function as below - it doesn't appear to get fired?

    <asp:HyperLink ID="PDF" NavigateUrl='<%=GetItemUrl(thisText) %>' runat="server" />

    We have tried Response.Write("hello world") as the function to prove the case.

    Is editing the control template the way forward of should we create a new user control for News?
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    13 Oct 2009
    Link to this post
    Hi homepagedigital,

    Create a new class that inherits from NewsView, override SingleItemTempalte path and ItemListTemplate path properties. Create a control constraint for your HyperLink control. Add the ResolveUrlMethod to this class. Then override SetItemMetaData method where you can access to the content item object and resove the value from the metakey as a url.

    Sample code:

    class NewsViewCustomControl: NewsView
    {
         
        public NewsViewCustomControl()
        {
        }
     
        
        // SET MASTER AND DETAIL MODE TEMPLATES
        public override string ItemListTemplatePath
        {
            get { return "~/Sitefinity/ControlTemplates/News/ListPageMaster.ascx"; }
        }
     
        public override string SingleItemTemplatePath
        {
            get { return "~/Sitefinity/ControlTemplates/News/ListPageDetails.ascx"; }
        }
     
        //override SetItemMetadata method.
        protected override void SetItemMetadata(System.Web.UI.Control itemContainer, IContent contentItem)
        {
            base.SetItemMetadata(itemContainer, contentItem);
            HyperLink link = (HyperLink)itemContainer.Controls[0].FindControl("PDF");
            if (link != null && contentItem.GetMetaData("PDF") != null)
            {
                string text = (string)contentItem.GetMetaData("PDF");
                
                    text = LinkParser.ResolveLinks(text, this.GetUrl);
                    link.NavigateUrl = text;
                 
            }
        }
     
     
     
        private string GetUrl(string value, Guid id, bool resolve)
        {
           // resolve the url
        }
    }


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. homepagedigital
    homepagedigital avatar
    13 posts
    Registered:
    06 Jul 2009
    13 Oct 2009
    Link to this post
    Created the class as provided and filled in getUrl as appropriate - understand what you've done here and this gives us a good insight moving forward on other stuff.

    However ....

    We are now being slow !!!

    How do we tell SiteFinity to use this extended version of NewsView?
  7. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    13 Oct 2009
    Link to this post
    Hi homepagedigital,

    If your custom control .cs file is located in the ~/App_Code dir, and you can add the control to your toolbox controls with the following line:
    <toolboxControls>
        <clear/>
        ...
        <add name="My News View" section="News" type="NewsViewCustomControl, App_Code" description="Add description here."/>
        ...
    </toolboxControls>

    Then you can take a look at the following article, to see how to hide the original control in the toolbox: How to hide controls from toolbox section in Sitefinity

    Sincerely yours,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
7 posts, 0 answered