Embed multiple files in theme page type
Permalink
I'm using Tony's Multiple File Attribute (http://www.concrete5.org/marketplace/addons/multiple-files-attribute/) to attach several documents to a page type template. I would like to include links to those documents within the template. Using returns a list of file IDs like: 1304,1303,1300,1298. So understandably something like won't work for this. How can I parse these out into actual links?
echo $c->getAttribute('files')
$c->getAttribute('files')->getVersion()->getRelativePath()
I had tried that, but when I do I get a PHP error: Warning: Invalid argument supplied for foreach()
When I do a print_r I get the same result: 1304,1303,1300,1298
if he really outputs a string you have to split it and use something like File::getByID to get the actual object
he even created a method which does that for you.
MultipleFilesAttributeTypeController::getFiles
MultipleFilesAttributeTypeController::getFiles
Thanks Remo - I'll mess around with that.
Just tried to get this going myself, did the following
$page = Page::getCurrentPage(); $images = $page->getAttribute('files'); $getFiles = MultipleFilesAttributeTypeController::getFiles($images); foreach($getFiles as $file){ echo $file->getVersion()->getRelativePath(); }
I'd recommend using print_r instead of echo to get the complete structure of the object.