21310 Posts in 5739 Topics by 2604 members
| Go to End | Next > | |
| Author | Topic: | 3381 Views |
-
PDF Download link

22 May 2010 at 1:11am
hello to everyone....
i'm trying to make a download link for pdf file in my application... but
unable to get any thing productive yet. I'm uploading pdf file through admin panel and want user to
download them in front end...please help
-
Re: PDF Download link

22 May 2010 at 9:13pm
How have you setup the backend? Are you simply uploading in the file and images section or are you attaching to a page via a FileField.
If you have done the former and you want to include the file in a page you should select the link text in the content editor (well the text you want to link to the file) and click the link icon in the tinymce toolbar. You can then select the file you want to make the link too.
If you are going to do the FileField / relationship option (such as tutorial 2 shows you with attaching images) then you should have a has_one relationship setup then in the templates you can use $NameOfFileField to get the pdf file you have uploaded - you can then use any methods like Link, Title on that to get a download like eg <a href="$NameOfFileField.Link">$NameOfFileField.Title</a>.
-
Re: PDF Download link

25 May 2010 at 5:37pm
Hello Willr
Sory for replying so late.
i'm using$f->addFieldToTab( 'Root.Content.PdfFile', new FileIFrameField('PDF', 'Upload and Attach PDF') );
to enable admin to upload file and maintaining relation asstatic $has_one = array( 'PDF' => 'File' );
i'm able to show pdf in front end using <a href="$PDF.Link" >$PDF.Title</a> but i want user to download them by simply clicking on that link ... Now when user click on the link it get open .... although user can download them by right clicking and then selecting "save as"
option, but i don't want that option..and thanks for replying
-
Re: PDF Download link

25 May 2010 at 9:59pm
I don't think you have much control over whether the browser opens it or downloads it. Some browsers will override all downloading of PDFs (like safari) so not sure you can override that, you *may* be able to send it some header to force it as a standard file rather than pdf but not sure.
-
Re: PDF Download link

18 January 2011 at 9:20pm
Hello,
I'm trying to do the FileField / relationship option and have the following:
static $has_one = array(
'PDF' => 'File',
'Photo' => 'Image'
);function getCMSFields() {
$fields = parent::getCMSFields();$fields->addFieldToTab("Root.Content.Images", new ImageField('Photo'));
$fields->addFieldToTab("Root.Content.Files", new FileIFrameField('PDF'));
...The template:
<div id="PcFile">
<a href="$PDF.URL">$PDF.Title</a>
</div>Unfortunately, in the frontend there just appears a broken link:
<div id="PcFile">
<a href="/assets/"> </a>
</div>My file is showing up correctly in the backend and I finally want to offer the same link (with the icon of a .pdf/.doc) in the frontend.
What am I doing wrong??
Thx
-
Re: PDF Download link

18 January 2011 at 10:28pm
Hi hi-tech,
try this in your template:
<div id="PcFile">
<a href="$PDF.Link">$PDF.Title</a> //<a href="$PDF.URL"> is wrong imho
</div>Cheers,
Christian -
Re: PDF Download link

18 January 2011 at 10:34pm
Hi Invader,
I gave it a try and it leads to the same false result. The method "Link" leads so the following output: "/assets/" instead of "/assets/uploads/myfile.*"
| 3381 Views | ||
| Go to Top | Next > |



