How to get url of a file stored in attribute of a page?

Hi, I need to make a link to pdf file which is stored in attribute of page.

View Replies:
Mainio replied on at Permalink Reply
$fID = $c->getAttribute('your_file_attribute');
$url = View::url('/download_file', $fID, $c->getCollectionID());
xaritas replied on at Permalink Reply
As above, or, once you grab the $file object, you can do:

$downloadURL = $file->getDownloadURL();
$openURL = $file->getRelativePath();

The download path will attempt to apply file permissions, and send the file as a regular download. The relative path will simply link to the file. In my app, I use both, so the user can choose.
yasioo replied on at Permalink Reply
Thank you for reply. I try both solutions and I think I miss something because I get error:

"Fatal error: Call to a member function getAttribute() on a non-object in" on a line:

"$file = $c->getAttribute('my_pdf_file');"
Mainio replied on at Permalink Reply
Add this on top:
global $c;
yasioo replied on at Permalink Reply
Ok it works, thank you, but not in a way I thought would be. Please correct me if I'm wrong. Now I can point to url of a concrete file, right?

The point is, I need something else. My mistake was, I didn't describe my problem. You see, I create let say 10 subpages with file-atrribute which will store pdf file. Every subpage will have different pdf. Now, I want to create page-list template which will show a link to concrete pdf file. Is this possible?
Mainio replied on at Permalink Reply
Yes, that is possible, although I would probably do that with only listing the file set instead if you don't have any needs to represent them as pages. You can also apply attributes to the files themselves.

Here's an add-on for that:

Also possible with the PageList, just modify its view.php template to create your own, there are bunch of comments that help you further. And with the examples above you can get the link to those files.
adajad replied on at Permalink Reply
I was in a similar position a while back where I wanted to present my viewers with files including some description about the file. What I did was to create a block holding the file and also a description. You do need to add a new block for each file, but if you only have 10 files then it should be enough.

I don't really know if it is enough for you, but have a look at it here: