Actually there is a very simple way to achieve this.
All Generic Content
based modules (Generic Content, News, Blogs) have the ability to define custom meta fields. So the basic idea is to define a PDFAttachement meta field to News module, add control that will accept the URL of the attachement and then in SingleNews and/or NewsList control add hyperlink control that will display this URL (for your PDF attachement). That's the solution in short. I'll give you now some more detailed instructions.Defining a new meta field
Open the web.config file. In the <cmsEngine> section find the <metaFields> section. You'll see there numerous meta fields that modules use by default. Add the following key :
<add key="News.PDFAttachement" valueType="ShortText" visible="True" searchable="false" sortable="False" defaultValue=""></add>
Basically, you are telling Sitefinity that with each news item a PDFAttachement field, which is of ShortText type will be stored. So far so good. Now you need to provide some user interface in the admin area for your users to enter the URL of .PDF file for the news item.Modifying admin templates
Next thing you need to do is modify the templates that Sitefinity uses for inserting new news items and editing existing news items. To do so, you need to open in Visual Studio following files :
- ~/Sitefinity/Admin/ControlTemplates/News/ControlPanelInsert.ascx and
Observe how we have created the markup for e.g. Author meta field. You have two options here, you can just add TextBox control and set it's id to PDFAttachement (that's how Sitefinity knows that value of this textbox should be used for saving/displaying PDFAttachement meta field). The drawback of this solution is obviously that the user needs to know exact URL of the attachment (I assume that attachments would be uploaded through the File Manager). Another option you have is to create a custom control that would have maybe a "Select document to attach button". When this button is clicked, you can open RadWindow or something like that and provide a File System treeview, so your users can select the document they wish to attach. If you decide to use a custom control, make sure it implements ITextControl interface; it is the Text property that will be used as value of your meta field.
So, after you've done this, you have set up everything on the administration side. Users have the option to attach a document (by setting the .PDF document URL) to a news item, they can edit it later or remove it. The last step is to display this link on the news public control.
Displaying meta field values on public controls
Once again we are going to modify the templates, only this time we are going to do that for the public controls. Let's assume you only want the PDF attachment link to appear only when user opens a news item. In that case, you only need to modify the template for the SingleNews control. Open the following file in Visual Studio :
What you want to do in this template is very similar to what you have already done in the admin templates. You will add a Hyperlink control that has the id same as the meta key (PDFAttachement) so that Sitefinity knows that this is the control to which the value of that meta field will be bound. However, Sitefinity will only bind the Text property, so you are still left with setting the NavigateUrl. Here you can use a little trick, so your Hyperlink control looks like this :
<asp:HyperLink ID="PDFAttachement" runat="server" NavigateUrl='<% = this.Text %>'></asp:HyperLink>
Basically, you tell the control that the NavigateUrl property is same as the Text property of that control, and the text property will be set by Sitefinity.
And that's it.
Obviously you have countless options here... You could have added two meta fields (attachement file title ad attachement file url), or you can make the meta field to store the collection of files (delimited by semi-colon ";")... it is up to you, but this is the basic principle I would use if it is up to me to create this kind of functionality.
I hope this helps. Let me know if you need any clarifications.
All the best,
the Telerik team