Pull file attribute from page for add on
Permalink
Hi
I've been using the HTML5 Audio add on and want to develop it's use by putting it directly on to a page template and to then override the add on controller so that it pulls an audio file directly from the page it is on. The audio file attribute on the page is called talk_audio. The controller code for the add on is:
Any help appreciated.
I've been using the HTML5 Audio add on and want to develop it's use by putting it directly on to a page template and to then override the add on controller so that it pulls an audio file directly from the page it is on. The audio file attribute on the page is called talk_audio. The controller code for the add on is:
<?php namespace Concrete\Package\Html5AudioPlayerBasic\Block\Html5AudioPlayerBasic; use Concrete\Core\Block\BlockController; use File; use Loader; defined('C5_EXECUTE') or die("Access Denied."); class Controller extends BlockController { protected $btTable = "btHtml5AudioPlayerBasic"; protected $btInterfaceWidth = "600"; protected $btInterfaceHeight = "500"; protected $btCacheBlockRecord = true; protected $btCacheBlockOutput = true; protected $btCacheBlockOutputOnPost = true; protected $btCacheBlockOutputForRegisteredUsers = false;
Viewing 15 lines of 100 lines. View entire code block.
Any help appreciated.
Hi
Thanks for your help. I replaced the code and then added to my page type output. When I add that page to my site I encounter the follow error:
Class 'Concrete\Package\Html5AudioPlayerBasic\Block\Html5AudioPlayerBasic\Page' not found
I can confirm that there is an audio file on the page and that the file handle is the same as in the controller:
Thanks for your help. I replaced the code and then added to my page type output. When I add that page to my site I encounter the follow error:
Class 'Concrete\Package\Html5AudioPlayerBasic\Block\Html5AudioPlayerBasic\Page' not found
I can confirm that there is an audio file on the page and that the file handle is the same as in the controller:
public function view() { $c = Page::getCurrentPage(); $f = $c->getAttribute('talk_audio'); if(!is_object($f)){ $f = File::getByID(intval($this->fID)); } $fallback = File::getByID(intval($this->secondaryfID)); $fileInfo = $this->getFileInfo($f, $fallback); if ($this->titleSource == 'DESCRIPTION') { $fileInfo['title'] = $fileInfo['description']; } elseif ($this->titleSource == 'CUSTOM') { $fileInfo['title'] = $this->title; } $options = array (
Viewing 15 lines of 28 lines. View entire code block.
You need to add use Page; to the top of the controller.
Spot on. Thank you SO much.
with
And that will get the attribute from the page, if the attribute isn't set then it will get the one from the block.