Search…

X3 Photo Gallery Support Forums

Search…
 
sopax
Experienced
Topic Author
Posts: 40
Joined: 20 Feb 2009, 09:19

PDF files

06 Jan 2019, 14:28

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?
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: PDF files

06 Jan 2019, 23:00

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/.