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

Forums / Developing with Sitefinity / PDF attachment for news and events

PDF attachment for news and events

7 posts, 0 answered
  1. Hydo L
    Hydo L avatar
    98 posts
    Registered:
    31 Mar 2010
    21 Aug 2010
    Link to this post
    Hi,
    I am using sitefinity 3.7. Can any one please tell me, about adding new field for PDF attachment. I need also hyper link to download the PDF from the front end.

    Thanks,
    Hydo
  2. George
    George  avatar
    204 posts
    Registered:
    05 Sep 2006
    22 Aug 2010
    Link to this post
    Hi Hydo,

    You will need to add a new meta field for the News and events to hold the Url for the PDF, map the external templates for the front end and modify them. This way you will have the download displaying on the frontend. Please check the documentation for more info on the subject.

    Best,

    George
  3. Hydo L
    Hydo L avatar
    98 posts
    Registered:
    31 Mar 2010
    23 Aug 2010
    Link to this post
    I did add new meta fields in the news module and now I can upload the PDF. Now I need to display the Hyper link in News details page (Sitefinity\ControlTemplates\Generic_Content\MoreInfoDetails.ascx).

    Can you please send me code to insert (display) the hyper link only for the news items with PDFattachment.

    Thanks,
    Hydo
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    23 Aug 2010
    Link to this post
    Hello Hydo L,

    You could check UserManual , page 214  Adding Custom Fields. In the public template you should add HyperLink control inside the main repater control with ID="repeater". The ID of the HyperLink control should be the same as the metafield key. If the returned value is a dynamic link, you should resolve it

    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
  5. Hydo L
    Hydo L avatar
    98 posts
    Registered:
    31 Mar 2010
    23 Aug 2010
    Link to this post
    Hi,

    I did uploaded PDF from the news module insert and edit section and ID is "PDFattachment".

    When I inserted the code "<asp:HyperLink ID="PDFattachment" runat="server" ></asp:HyperLink>" in "MoreInfoDetails.ascx"  I can view the URL of the PDF file I uploaded on the front end.

    But I couldn't put the navigate URL there I tried "<asp:HyperLink ID="PDFattachment" runat="server" NavigateUrl='<%=Me.Text %>'></asp:HyperLink>", but doesn't work.

    Actually I need to Put the text as "Download Arabic Press release" and navigate URL as the URL od PDF attached.

    Please provide me more details.

    Regards,
    Hydo

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    23 Aug 2010
    Link to this post
    Hi Hydo L,

    Crate a custom control that inherits from NewsView. Override SitItemMetadata method. Find your HyperLink by using itemContainer parameter and set NavigateUrl and Text properties of your HyperLink.


    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
  7. George
    George  avatar
    204 posts
    Registered:
    05 Sep 2006
    23 Aug 2010
    Link to this post
    Hi Hydo L,

    The code would look like like this 

    namespace Telerik.News.WebControls
    {
    public class NewsViewWithPDF : NewsView
    {
        public override string ItemListTemplatePath
        {
            get
            {
                return "~/Sitefinity/ControlTemplates/News/ListPageMasterWithPDF.ascx";
            }
            set
            {
                base.ItemListTemplatePath = value;
            }
        }
         
        protected override void SetItemMetadata(System.Web.UI.Control itemContainer, Telerik.Cms.Engine.IContent contentItem)
        {
            base.SetItemMetadata(itemContainer, contentItem);
     
            var pdfControl = itemContainer.FindControl("PDFattachment") as HyperLink;
     
            if (pdfControl != null)
            {
                pdfControl.Text = "Download PDF";
                pdfControl.NavigateUrl = contentItem.GetMetadata("PDFattachment").ToString();
            }
        }
    }
    }

    Then add to the toolbox controls in the web.config the following

    <add name="NewsView PDF" section="News" type="Telerik.News.WebControls.NewsViewWithPDF, App_Code" />

    Cheers,

    George
Register for webinar
7 posts, 0 answered