Change Template
Moderator: General Moderators
Change Template
Let say I have a template of letter in my system (eg Formal letter - letterA.php). Is it possible if i want to change the template using my system. For example, i view the template (eg. Letter A) inside textarea. And then i change the template inside that textarea and click Save button. And then the template will be saved into the system. Anybody got any idea how to do it pls?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Yes it can be done. For example...
...
Code: Select all
Directories (for example):
'/home/user/public_html/'
'change_template.php'
'view_template.php'
'/home/user/public_html/templates/'
'template_1.htm'Code: Select all
<form action="e;change_template.php"e;>
<textarea name="e;document"e;>
<?= file_get_contents($template_path); ?>
</textarea>
<input type="e;hidden"e; name="e;template_path"e; value="e;<?= $template_path; ?>"e; />
<input type="e;submit"e; name="e;submit"e; value="e;Save"e;>Code: Select all
<?php
$tpl = stripslashes($_POSTї'template_path']);
$doc = stripslashes($_POSTї'document']);
$handle = fopen($tpl, 'w+');
fwrite($handle, $doc);
fclose($handle);
//do whatever
?>if you're on a windows server, you might also want to include a "b" for your mode parameter to force binary mode...just an idea to save you a headache if it doesn't work doing as d11 suggested:
Code: Select all
$handle = fopen($tpl, 'wb');