I want to include a piece of custom javascript....But
I only want this to happen if BannerPage has items in the DataObject Banner.
$this->ShowBanner can successfully check on a field within BannerPage.
But i want to check if this BannerPage actually has images in the Dataobject called Banner
---banner.php dataobject --that holds field bannerimage
class Banner extends DataObject {
}
-- BannerPage --
class BannerPage extends Page {
public static $db = array(
'ShowBanner' => 'Boolean'
);
}
class BannerPage_Controller extends Page_Controller {
public function init() {
parent::init();
if($this->ShowBanner){
Requirements::customScript("
myjscode",bannerjs');
}else {
}
}//init
}//controller
I previously did <% if Banners %> in template but i want to now add js via the Controller instead
Maybe i need to add a function ??
public function CheckBanners() {
return DataObject::get("Banner", "PageID = {$this->ID}");
}