Page 1 of 1

Method for saving Template into a file?

Posted: Thu Nov 01, 2007 1:48 am
by Augustas
Hello,

How can I save template to a file?

My module loads a template from /templates/ folder and displays in Admin's TextArea with

Code: Select all

$this->GetTemplateFromFile('templatename');
in order to edit the template.

But how can I save template back to the same file after changes are Submited, besides writing my own function?

I found only SetTemplate() method, which updates only template inside database.

Thanks.

Re: Method for saving Template into a file?

Posted: Thu Nov 01, 2007 3:34 am
by kermit
AFAIK, CMSMS only READS templates from files (such as the default menu templates), it doesn't write them to files, it stores edited ones in the database...

i don't use it but 'template externalizer' writes existing templates to files for editing via ftp.. maybe there's something in it you can use. http://dev.cmsmadesimple.org/projects/externalizer

Re: Method for saving Template into a file?

Posted: Thu Nov 01, 2007 3:49 am
by Dr.CSS
He's trying to make a module with an editable template like news does...

Re: Method for saving Template into a file?

Posted: Thu Nov 01, 2007 6:43 am
by Duketown
augustas,

Maybe you have some help on the manual part that I wrote about this topic. See:
http://wiki.cmsmadesimple.org/index.php/User_Handbook/Developers_Guide/Creating_Modules#Insert_database_driven_templates

Duketown

Re: Method for saving Template into a file?

Posted: Thu Nov 01, 2007 1:43 pm
by Augustas
Well, I need to save edited template into a file, not database.

Seems CMSMS does not have anything built in, so I simply wrote a function SaveTemplateToFile($name, $content)
with few lines of opening a file and placing a content :)