Method for saving Template into a file?

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
User avatar
Augustas
Forum Members
Forum Members
Posts: 241
Joined: Wed Oct 17, 2007 6:09 pm
Location: the world

Method for saving Template into a file?

Post 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.
http://FollowTheRoad.com/ - living on the road...
http://www.kligys.com/ - asmeninis blog'as...
User avatar
kermit
Power Poster
Power Poster
Posts: 693
Joined: Thu Jan 26, 2006 11:46 am

Re: Method for saving Template into a file?

Post 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
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: Method for saving Template into a file?

Post by Dr.CSS »

He's trying to make a module with an editable template like news does...
Duketown

Re: Method for saving Template into a file?

Post 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
User avatar
Augustas
Forum Members
Forum Members
Posts: 241
Joined: Wed Oct 17, 2007 6:09 pm
Location: the world

Re: Method for saving Template into a file?

Post 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 :)
http://FollowTheRoad.com/ - living on the road...
http://www.kligys.com/ - asmeninis blog'as...
Post Reply

Return to “Developers Discussion”