How to get url of a file stored in attribute of a page?
$fID = $c->getAttribute('your_file_attribute'); $url = View::url('/download_file', $fID, $c->getCollectionID());
$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.
"Fatal error: Call to a member function getAttribute() on a non-object in" on a line:
"$file = $c->getAttribute('my_pdf_file');"
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?
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.
I don't really know if it is enough for you, but have a look at it here: http://www.concrete5.org/marketplace/addons/file-with-description/...