Hello, i try to build a demo page for css & javascript stuff.
Every page needs a custom css and a javascript file in its <head> - but its harder than i though.
The DemoPage Controller contains two file fields like this:
class DemoPage extends Page {
static $has_one = array(
'JS_file' => 'File' ,
'CSS_file' => 'File'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new FileIFrameField('CSS_file'));
$fields->addFieldToTab('Root.Content.Main', new FileIFrameField('JS_file'));
[...]
An here the template:
[...]
<head>
<% base_tag %>
<link rel="stylesheet" type="text/css" href="/assets/demos/css/basic.css" />
<% if CSS_file %>
<link rel="stylesheet" type="text/css" href="$CSS_file" />
<% end_if %>
<% if JS_file %>
<script type="text/javascript" src="$JS_file"></script>
<% end_if %>
[...]
When i attach a file and open the page i get the following error:
FATAL ERROR: Object::__call() Method 'forTemplate' not found in class 'File'
At line 199 in /opt/lampp/htdocs/port/sapphire/core/Object.php
user_error(Object::__call() Method 'forTemplate' not found in class 'File',256)
line 199 of Object.php
and so on....hm i don't get it! tips would be great ^^