How can link to a file form another subpage with (file:)?

Hi,

is ist possible do provide a download link using (file:file.pdf text:demo file), when the file is in the folder of another page. For example

contents/1-page/default.txt
contents/downloads/file.pdf

Now I want to link from 1-page/default.txt to downloads/file.pdf but (file:downloads/file.pdf text:demo file) doesn’t create a link.

Cheers,
Tobi

Try file instead of link.

Ops. Actually I’m using file already …

Hint:
Add one space (" “) after every colon (”:") for every tag in the brackets!

e.g.:

(link: downloads/file.pdf text: demo file)

Good luck!

Why? It seems to make now difference …

To understand:
The combination ": " (one space after a colon) is required for parsing the text in the brackets by Kirby.

Hm … but (file:file.pdf text:demo file) works fine if the file and the text are in the same content folder. Are you sure that the space is mandatory – I’d say it isn’t …

Do, what you want to do, but it stays as my hint to you.
Within my websites my hint works in every bracket.

Good luck!

[Edit:]
I never have used “file:”, I always use “link:” to show the linked file with “popup: yes” in another tab/window of the browser.

From where do you get this information? If that was true, it would be quite error prone and I have never come across such a problem ever.

@texnixe:
I got this by “try and error” within the used old Kirby versions. I started development with version 1.x.
My hint works with “kirby-nightly-2.1.0-20150507112900.zip” too:

e.g. in file “content\2-projects\2-project-b\project.txt”:

Title: Project B

----

Year: 2013

----

Tags: city

----

Text: 

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.
You can (link: projects/project-a/forrest.jpg text: download a pic popup: yes) from project-a.

Well, there is nothing in the source code to support your assumption, at least not in the current 2.0.6 or 2.1.0 beta versions, so this hint is not likely to solve the problem.

[Edit] Rather,it seems that the link tag works with a path while file doesn’t seem to work. Need to look into this a bit more. I briefly tested this in a current starter kit with a downloads folder in /content:

(link:downloads/test.pdf) //works
(file:downloads/test.pdf) //does not work
(file:test.pdf) //in same folder, works

@anon77445132: I didn’t say that your hint is wrong, only that it makes no difference in my case, an I came never through issues caused by a missing space. If there’s such an issue I’d consider it as a bug.

@texnixe: Thanks, I had a look at the code to but wasn’t able wo find a solution with my basic PHP knowledge …

Do we consider the difference between file and link as a bug? If so I’d open an issue und GitHub.

[Edit:] The Docs say

Provide a download link to a file in your page’s content folder.

According to this it is the right behavior of file. But maybe this should be changed, though.

Well, it says the same with regard to the image tag

You can easily embed any images from your page’s content folder.

And the image tag works with a path as well, so I’d regard this as a bug.

I opened a new issue: https://github.com/getkirby/kirby/issues/247

1 Like