3214 Posts in 848 Topics by 810 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1249 Views |
-
Include contents of html-file choosen from FileFrameField in backend

29 January 2009 at 10:03am
Hi,
I've created a new page type called IncludeHTML. In this pagetype I've added a File field, and a CMSfield of the type FileFrameField.
This allows me to choose a html-file uploaded to the assests folder or upload one from my computer.
My goal now is to get the contents of this html-file included in my IncludeHTML-template (IncludeHTML.ss) wherever I choose to put it. As an example $IncludeHTML ... should output the source code from the html-file chosen in the backend. This would ease my work load when including image maps etc.Any ideas on how to get this done in a neat way?
-
Re: Include contents of html-file choosen from FileFrameField in backend

29 January 2009 at 10:34am
Could probably just do
function IncludeHTML()
{
return file_get_contents(Director::baseFolder().'/'.$this->MyFileField()->Filename);
} -
Re: Include contents of html-file choosen from FileFrameField in backend

29 January 2009 at 10:44am Last edited: 29 January 2009 10:45am
Hi, thank you for a rapid reply!
Should I use <% includeHTML %> in the .ss file?
Could you place the right MyFileField etc. in the code below for me (I'm new to all this!!)<?php
/**
* Defines the InkluderPage page type
*/
class InkluderPage extends Page {
static $db = array(
);static $has_one = array(
'FileInclude' => 'File'
);function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Inkluder", new FileIFrameField("FileInclude"));
return $fields;
}
}class InkluderPage_Controller extends Page_Controller {
function IncludeHTML()
{
return file_get_contents(Director::baseFolder().'/'.$this->MyFileField()->Filename);
}
}
?>
| 1249 Views | ||
|
Page:
1
|
Go to Top |

