Page 1 of 1

PDF files

Posted: 06 Jan 2019, 14:28
by sopax
I have tried several different ways - unsuccessfully - to open a .pdf document, which has been uploaded to the site. When clicking on the link, the usual black window appears - empty. Does it take a lot of programming to allow .pdf files to be shown?

Re: PDF files

Posted: 06 Jan 2019, 23:00
by mjau-mjau
To link to files uploaded to a page, you must use the {{path}} variable:
Code
<a href="{{path}}file.pdf">View PDF</a>
// or markdown:
Code
[View PDF]({{path}}file.pdf)
Why?
If you just use links likeĀ href="file.pdf", you are instructing the browser to locate the file relative to the page's URL, but the URL is not an actual file path on your server. Just like most modern web applications, URL's are "virtual" and user-friendly. In most cases however, the file path in X3 can be extrapolated by simply prepending /content/ to the URL. For example, URL /animals/dogs/ would normally have file path /content/animals/dogs/.