Link to a pdf

6 posts by 2 authors in: Forums > CMS Builder
Last Post: December 20, 2010   (RSS)

Hi

What's the best way to upload a pdf file and have a direct link to it on the front end of my site. A new version of the pdf will be uploaded reguarly so I want the old file to be overwritten by the new one. The link on the front end should then update automatically.

Thanks

Re: [paulmac] Link to a pdf

By Jason - December 20, 2010

Hi,

The best thing to do would be to create a single record section. You would then add an upload field to this section that will only accept 1 pdf file. If you want to replace that pdf, you just remove it and upload a new one.

On your front end, you just access the upload field of that single record section. Whenever that file is changed, the change would be reflected on those pages.

Hope this helps. Let me know if you run into any problems.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Link to a pdf

Hi Jason

Would you have a sample of the code to use on the front end.

Thanks

Re: [paulmac] Link to a pdf

By Jason - December 20, 2010

Hi,

In this example, we'll use a single record section called additional_information. In that section we'll have an upload field called "pdf" that only allows 1 pdf to be uploaded at any given time.

list($additionalRecord,$additionalMetaData)=getRecords(array(
'tableName' => 'additional_information',
'allowSearch' => false,
'limit' => 1,
));
$additional = $additionalRecord[0]; //get first record


We can now output a link to our pdf:

<?php if($additional['pdf']): ?>
<?php $pdf = $additional['pdf'][0];?>
<a href="<?php echo $pdf['urlPath'];?>">Download</a>
<?php endif ?>


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [paulmac] Link to a pdf

By Jason - December 20, 2010

Hi,

You would upload the file through your sections upload field. You can set this field to upload to a specific directory if you don't want to use the default "uploads" folder.

If you only want to have one brochure available at any given time, the best thing to do would be to limit the field to only allow 1 upload. If you want to then put up a new brochure, just use the "remove" link beside your current brochure inside CMS Builder and then upload your new pdf. The code you use won't have to change, it will link to whatever file is currently uploaded.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/