Hi,
I've created a module which outputs a particular text file. I also have some fields that I have added to SiteConfig (which works fine and can be used from page templates).
However, I'm having trouble getting this module's template to use the SiteConfig data...
Here is my code:
mytextfile/_config.php
<?php
// adds a rule to make www.site.com/myfile.txt work
Director::addRules(10, array(
'myfile.txt' => 'MyTextFileDownload',
));
// add the extension to SiteConfig
Object::add_extension('SiteConfig', 'TextFileExtrasDecorator');
?>
mytextfile/code/MyTextFileDownload.php
class MyTextFileDownload. extends Controller{
function index($url) {
return array();
}
}
mytextfile/code/TextFileExtrasDecorator.php
<?php
class TextFileExtrasDecorator extends DataObjectDecorator {
function extraStatics() {
return array(
'db' => array(
'AuthorName' => 'Varchar',
)
);
}
public function updateCMSFields(FieldSet $fields) {
$fields->addFieldToTab("Root.ExampleTextFileDetails", new TextField("AuthorName", "Author"));
}
}
?>
mytextfile/templates/MyTextFileDownload.ss
Here is my example text file.
The author is: $SiteConfig.AuthorName
This is the end of the file.
When I access this file (eg. www.site.com/myfile.txt) I am able to download the file, but what I get is:
Here is my example text file.
The author is:
This is the end of the file.
Interestingly, I have no trouble accessing $SiteConfig.AuthorName from any normal page template.
Any ideas?
Thanks very much.
VWD.