PDA

View Full Version : Save template to textfile


Fryzid
05-01-2001, 03:04 PM
To compare templates easily I'd like to have a script that will save each template of a style to a textfile named like the template or even something like styelid_templatename.txt.

I think its easier to update modified or translated templates when you can use a comparison tool like BeyondCompare for example.

Perhaps someone has got the time to make this script. I don't have it right now. :(

Thanks.

SteveK
05-01-2001, 03:20 PM
Definately needed!

Fryzid
05-02-2001, 06:42 PM
Here's the script. Not very nice but works for now:
get the script in the next post

Put the script in your admin dir.
Just change the $tempsetid to save a different template set.
All templates will be saved in a directory called after the templatesetid.
Perhaps I will improve it later....

Fryzid
05-10-2001, 12:30 PM
Now it's much nicer with the ability to select the style via dropdown box.
You can name the directory now. If you leave the field blank it will name the directory after the templatesetid.

Put the script in your admin dir an run it.

I hope you can read german ;)

Christian
05-10-2001, 12:48 PM
I have dared to translate it into English! ;)

If you want me to remove the English version from this post just tell me!

Christian
05-10-2001, 01:12 PM
One question:

I got a lot of error messages as I ran it!

I tried it then with your original German version and it was the same!

Can it be that it only works with Windows servers?

Fryzid
05-10-2001, 02:27 PM
What kind of error messages?

I only used it on my Windows machine.

Christian
05-10-2001, 02:58 PM
I guess it only works with Windows:


Directory ./templates doesn't exist! Being created...

Warning: MkDir failed (Permission denied) in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 25

Warning: fopen("./templates/headinclude","w") - No such file or directory in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 33

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 34

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 35

Warning: fopen("./templates/timezonelist","w") - No such file or directory in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 33

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 34

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 35

Warning: fopen("./templates/footer","w") - No such file or directory in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 33

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 34

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 35

Warning: fopen("./templates/whoposted","w") - No such file or directory in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 33

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 34

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 35

Warning: fopen("./templates/whopostedbit","w") - No such file or directory in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 33

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 34

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 35

Warning: fopen("./templates/forumdisplay_threadslist","w") - No such file or directory in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 33

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 34

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 35

Warning: fopen("./templates/forumdisplaybit","w") - No such file or directory in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 33

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 34

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 35

Warning: fopen("./templates/showmoderators","w") - No such file or directory in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 33

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 34

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 35

Warning: fopen("./templates/timezone_city","w") - No such file or directory in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 33

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 34

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 35

Warning: fopen("./templates/timezone_city_col","w") - No such file or directory in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 33

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 34

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 35

Warning: fopen("./templates/forumhome","w") - No such file or directory in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 33

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 34

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 35

Warning: fopen("./templates/welcome","w") - No such file or directory in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 33

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 34

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 35

Warning: fopen("./templates/messagecenter","w") - No such file or directory in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 33

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 34

Warning: Supplied argument is not a valid File-Handle resource in /home/ledge/public_html/tke/forum/admin/savetemplates.php on line 35

All Files have been successfully created in templates !


Nothing is created!

Wayne Luke
05-10-2001, 09:13 PM
Create your directory and chmod it 777.

wacnstac
05-13-2001, 11:31 AM
I get the following error when I run this utility:

Fatal error: Call to undefined function: maketableheader() in /home/msports/michigan-sportsman-www/forum/admin/savetemplates.php on line 47


Any ideas? I desperately need to run this utility to make upgrading my templates managable.

Fryzid
05-13-2001, 01:55 PM
this function is not in previous vb versions. so try this script
<?php

require("./global.php");
$noheader=1;

cpheader();

//echo "Writing templates into Files:<br><br>";

//set these vars
$templatesetid = "-1"; // -1 for master, any other number for the templateset you want to save
$pfad = ""; // leave empty or any name for the dir you want to save the templates to. don't forget to create the dir and chmod 777 it on *nix systems before running this script if php isn't allowed to create dirs


$tempsetid = $templatesetid;
$templates = $DB_site->query("SELECT templatesetid,templateid,template,title FROM template WHERE templatesetid=$tempsetid");
if ($pfad=="") $pfad = $tempsetid;
if (file_exists("$pfad")) {
echo "Directory ./$pfad exists!";
} else {
echo "Directory ./$pfad doesn't exist! Being created...<br>";
mkdir("$pfad", 0777);
//echo "Directory ./$pfad was created!<br>";
}

while ($template=$DB_site->fetch_array($templates)) {

//echo "Write ./$tempsetid/$template[title]<br>****************************<br>";

$templatefile=fopen("./$pfad/$template[title]","w");
fwrite($templatefile,$template[template]);
fclose($templatefile);
}

echo "<br>All Files have been successfully created in $pfad !";

cpfooter();
?>

i hope this will do it.

Streicher
05-13-2001, 05:01 PM
Can a moderator move this thread to the Releases-Forum

Streicher
05-27-2001, 08:50 AM
*bump* Can this hack be moved to the other releases please. This hack would be helpful for other members.

wacnstac
05-27-2001, 12:00 PM
Yes indeed it would!

wacnstac
10-21-2001, 04:02 PM
Does this hack work with 2.03 or is it incompatible? I need to compare the new 2.03 templates with my old 2.01 templates. The hack seems to wirte my old 2.01 templates out fine, but the 2.03 templates never seem to get written out....

pogo
10-21-2001, 07:42 PM
It works fine for me.

wacnstac
10-21-2001, 07:52 PM
Ok, thanks.

Thomas P
11-02-2001, 10:03 PM
Works great with 2.2.0 and wayne's hint to create and chmod a dir before calling the script...
Veeery useful :)
-Tom

Admin
11-03-2001, 07:05 AM
I'm thinking about writing a piece of code that can:
a) Write all templates to text files (kinda like this)
and more important
b) Can read all templates from text files and update database accordingly.

Why?
This would be great for upgrading. You can make two folders, one of the new templates (let's say the original v2.2.0 template), and another one for your customized template (let's say your own v2.0.3 template).
Now you can use something like Araxis or Beyond Compare to compare the files, update, and save everything to the database with ease!

Dynamic One
11-14-2002, 08:23 PM
Thanks for this handy tool (hack) m8.

Xenon
11-15-2002, 08:12 PM
Dynamic One, please use another sig image, you are over the 300 pixels wide limit and over the 20k in size limit.