PDA

View Full Version : Export and import templates to individual files!


Chen
27 Nov 2001, 17:10
I'm releasing this as beta because:

This has not been tested enough to prove it's working 100%.
Your templates aren't something that can be compromised.


In short, what does this hack do:

Can write all your templates into files, with any extension you'd like (.html is my favorite), having each template in its own file.
Can read from existing template files and save them back to your forum system.
Now with option to selectively choose what templates to import / export!


To install:

Download the attached ZIP file, extract it and upload do_template.php to your forum admin folder.
Go to the file in your browser.

If you are not on a Windows server, make sure PHP has permission to write (CHMOD 0777) in the folder you specify.
If the folder doesn't exist, PHP will attempt to create it, but you will need write permissions (CHMOD 0777) in the parent folder of it.


Please test this if you can.
If you're trying this out on your real board, it should be safe, but I highly recommend backing up your styles before using it.

This is the place to make suggestions, I expect some! :)

snyx
27 Nov 2001, 20:40
whoa, me likes this concept man!
I will install it on a dummy system asap, and get back to ya!

Parker Clack
27 Nov 2001, 20:47
Chen:

I just installed it on my server and it works like a champ at downloading them. I haven't try to upload any of them though. It would be cool if you could pick out which ones you would like to import instead of importing them all.

Parker

SteveK
27 Nov 2001, 23:39
I've just tried downloading once in text mode and it works great. Will try other file types and importing later.

How about the ability through the interface to delete previously saved directories of templates. Since the directory and files are written by www, you can't easily remove them via ftp.

Another idea would be the ability to save the templates in a user specified directory besides the forum/admin directory. Best would be below root but don't know if this is possible.

And one more idea would be a drop down box that would allow you to select just a few templates to download vs. a complete dump of all templates.

Okay, just one more idea.... how about being able to zip them up and send the downloaded templates out to us via email?? This is handy as many times I'm not on a system that I can FTP from (due to company proxy settings)

This is a great tool and will make template life much easier!

Steve

Parker Clack
28 Nov 2001, 06:38
When you import a template do you have to delete the other template first before importing or does it just write over the top of the old one?

I agree that a file that is created that you could download as one big file would be great. What if you wrote it so that all of the information is written to one file, like the style file is, and then you could just import that one file back in.

This is a great idea and I know it will be utilized a lot around the sites with vB.

Thanks again,
Parker

Chen
28 Nov 2001, 11:37
Originally posted by Parker Clack
Chen:

I just installed it on my server and it works like a champ at downloading them. I haven't try to upload any of them though. It would be cool if you could pick out which ones you would like to import instead of importing them all.

Parker
To only import some templates, you can delete all the others you don't want.
Also (not sure if I mentioned this already :)), the script only updates templates that have changed.
If you try and only edit one file, and then updating the templates, you'll see only that template is listed as updated, and all the others were skipped.

Chen
28 Nov 2001, 11:44
Originally posted by SteveK
I've just tried downloading once in text mode and it works great. Will try other file types and importing later.
To clarify, selecting .zip as the extension won't actually make the files zipped! They will still be in text mode.

How about the ability through the interface to delete previously saved directories of templates. Since the directory and files are written by www, you can't easily remove them via ftp.
That would require either saving all templates folders to the database in a special table, or having a script to go through the server and letting you do stuff with folders.

Another idea would be the ability to save the templates in a user specified directory besides the forum/admin directory. Best would be below root but don't know if this is possible.
AFAIK, you can't CHMOD folders below your public folder. Because of that, PHP won't be able to write to these folders.
TBH I don't really see the need for specifying folders that deep. :stupid:

And one more idea would be a drop down box that would allow you to select just a few templates to download vs. a complete dump of all templates.
Ok, I think I will add some kind of select box you can select templates from. Altough it would be very hard for the user to select all templates he wants, if there are a lot of them.

Okay, just one more idea.... how about being able to zip them up and send the downloaded templates out to us via email?? This is handy as many times I'm not on a system that I can FTP from (due to company proxy settings)
I actually thought of that, and I was sure it's a great idea.
The problem is, not all servers can zip files/folders on the server, because a special module is needed. And most servers don't have this. :(

This is a great tool and will make template life much easier!

Steve [/B]

Chen
28 Nov 2001, 11:47
Originally posted by Parker Clack
When you import a template do you have to delete the other template first before importing or does it just write over the top of the old one?

I agree that a file that is created that you could download as one big file would be great. What if you wrote it so that all of the information is written to one file, like the style file is, and then you could just import that one file back in.

This is a great idea and I know it will be utilized a lot around the sites with vB.

Thanks again,
Parker
If you import a template that already exists, the original template is overwritten (if it's a modified template), and if it's a default template a new template is added to the template set. (don't worry, it's exactly how it works with the admin cp :))

Doing what you just said, exporting to one file and importing from it, is exactly how it's being done today.
This is a bad way to upgrade, IMO (and others'), and it's why I created this script.
So doing what you suggested will actually be a step back. :)

Chen
28 Nov 2001, 11:49
To demonstrate what the main intention of this hack is:
Let's say you upgrade from v2 to v3.
So you download your current (modified) v2 templates, and to another folder you download the original v3 templates.
Then you can use something like Beyond Compare or Araxis Merge to compare the two folders, on a file to file basis.
Then when you're done, you just upload the templates back to a folder, and import them back using this script.

Chen
28 Nov 2001, 14:17
Ok, so I worked this afternoon about this, and now you have an option to selectively choose which templates to import. (see screen shot)

I'm not working on the same thing for the export process. (which is a bit more complicated than I thought!)

Heh, it took me 20 minutes (and a Google search ;)) to realize I need to put [] next to the input name when doing:
<select name="blbla[]" multiple>
:p

Chen
28 Nov 2001, 14:27
Finally. :)

Now you can select which templates to export or import then you run the script (there is a little drop down menu for selecting Yes or No).

Just upload the new file to 'upgrade'. ;)

Parker Clack
29 Nov 2001, 12:43
Chen:

Thanks for the upgrade and the explanation.

Great hack!!

Parker

FWC
02 Dec 2001, 00:11
This is very cool, Chen! :)

Hooper
02 Dec 2001, 04:46
Good Grief Chen,

I don't know which is better. The new hack for including WOL links. Or this. Or the Advertisement hack.

They are all great. I have been backing up my templates into text files by hand since I purchased vBulletin. This is unreal. What took me a half hour now litteraly takes me less than 5 seconds. And the select what templates to import and export....all I can say is WOW. I went ahead and added it to the Admin CP.

---------------------------------------------------------------------------------

Question: When downloading a template set other than the default it always says that it downloaded the default. What might cause this? It seems to be backing up the correct template set, but for some reason it says default no matter what the name of the template set is. Sorry if someone already asked.

Question: I am not seeing a section that says downloading Users Custom Templates. What might be the cause of this? Sorry if someone already asked.

---------------------------------------------------------------------------------

Thanks Chen.

Crinos
02 Dec 2001, 12:10
Installed and working great for downloading the template files :)

Haven't tried the import feature yet though

Chen
02 Dec 2001, 13:53
Why is it saying Default all the time?
When it says "Done exporting default templates!", it doesn't mean it exported the default template set, but it just means it's done exporting templates that weren't changed in the template set you selected.
(these are the templates that are colored green in the template list)

You're not seeing the part where it says downloading Users Custom Templates?
Maybe you have no custom templates in the template set you selected. Are you sure you have some?
Also does it say something like "No custom templates to export"!, or just displays nothing? A screen shot would help. :)

Originally posted by Hooper
They are all great. I have been backing up my templates into text files by hand since I purchased vBulletin. This is unreal. What took me a half hour now litteraly takes me less than 5 seconds. And the select what templates to import and export....all I can say is WOW. I went ahead and added it to the Admin CP.
You have no idea how good it feels to read this kind of stuff. Makes hacking so great. :) Thanks.

I want to release this as a proper release, so please expermient with it as much as you can. Backup your style and start doing some funky stuff, everything you can possibly think of!
My biggest concern is that it won't overwrite the original template set (-1), although there is code in the file that prevents it, you can never know.

Thanks. :)

Hooper
02 Dec 2001, 18:10
Welcome! :D

Oh yeah. I have a bunch of custom templates in 2 different styles. It says nothing at all about downloading them. Nor are they there when I check the server for them. I've tried both the News Template set and my Main set. I'll work on this today and post some shots. But never does it say anything about the Custom User Template set.

Any chance of having the name of the set you are backing up and importing to have the name on it. With this being the templates, It makes a user quite ..well....let's say "On the edge" with not seeing exactly what is going on. So If I had seen the name of my template set before and after the backup, I will feel much more comfortable with the situation.

Backing up News Templates.....DONE! :D

I have a a bunch of customized and quite a few custom templates.

Thanks Chen

FWC
02 Dec 2001, 18:38
Originally posted by Hooper
Oh yeah. I have a bunch of custom templates in 2 different styles. It says nothing at all about downloading them. Nor are they there when I check the server for them. I've tried both the News Template set and my Main set. I'll work on this today and post some shots. But never does it say anything about the Custom User Template set.It did back up all my custom templates. I told it to grab the whole set and it took everything. Weird.

Hooper
02 Dec 2001, 18:41
Yes it is weird. It didn't back up my Custom User Templates at all.

What I would like to see is


Downloading....Custom User Template Set

Downloading.... News Template Set

and so on.... Only saying default if it is indeed the default template set that is being up or downloaded.

Having 5 sets and always seeing Default is just not going to satisfy my nerves when I am messing with a bunch of highly changed templates and days (scratch days... Try weeks) of hard work.

I need to know what it is doing... :D

Chen
02 Dec 2001, 18:58
Hooper, I really have no idea what could be wrong.

Anyway, I re-did the whole way you are shown templates that are exported / imported - you should be satisfied with this version.
They are now displayed in one big table, with [edit] links next to each template(!!!). :p

Also new, in the select box where you select templates to export / import, original temlpates are colored green, and modified templates are colored blue. How user friendly is that? :D

Just finishing it off and I'll put the new version up in a bit.
Now that I have the [edit] link, please test it and make sure it really links to the right template! :)

Chen
02 Dec 2001, 19:00
Ok new file is up, download and upload! :)

Hooper
02 Dec 2001, 19:51
I downloaded with Opera and am getting a different file. WinXP IE 6 is screwed on my end.


Ah.... Yes. Much better Chen. I now not only can see what templates are what, they are devided, color coded and EDITABLE? :D

Wow..... Better than I asked for. I downloaded and verified manually that it was done correctly. I'll work on the import this after noon and post my finds.

Thanks for the update, this is much better.

FWC
02 Dec 2001, 21:31
Wow!! I thought the first version was great. This new version is incredible!! Awesome work, Chen. :D

Chen
03 Dec 2001, 13:08
Thanks guys. :D

I would like a button that will automatically select all custom templates... problem is my Javascript knowledge is very limited so I have no idea where to begin with it.
If anyone can give me a hand it would great. :)

Maybe add a yes/no button to say "Only export / import custom templates"? Any thoughts?

FWC
03 Dec 2001, 18:08
Originally posted by FireFly
Maybe add a yes/no button to say "Only export / import custom templates"? Any thoughts? Sounds good to me! Who knows javascript around here? :D

Hooper
03 Dec 2001, 19:27
I agree,

It would be a whole lot nicer and more functional to be able to select by grouping and individual files. In other words, instead of backing up and overwriting ALL templates, it would be super to go in and grab templates by sets with a way to include only desired templates. Ex. Custom Templates, User Templates, or what have you. With individual selection next to desired templates to back up. I'm picturing a radio button selection with the heirachy set as within the control panel for grouping. Super if we could see the edit/expand full template scheme with individual file selection. (radio)

At the present if you modify a few templates, you will be backing up all of the templates including the templates that are not modified. If this could be set up in such a way that templates were able to be selected individually ...( say by having a selection next to it) we wouldn't have to over write templates within the folder nor would we have to download all the non modified templates every time.

Chen how difficult would it be to have a "selectable by group or file" type system with a "select all" funtion?

This would give the user the overall protect your files and backup plan, while allowing for the person modifying specific templates to keep on top of things also.

Yes. We need this. :) Do you really need javascript for this? Why couldnn't we use the vBulletin file that expands the templates for edit? Iwouldn't mind seeing something like the edit template pages for backup. You could expand the groups and choose the templates you wish. We would however need a "Select All" function as well as a "Clear all selections".

Also, if they are going to tag names with hacks around here I would ask that they find the file attatched to my name and remove it. Whatever the heck Imp is. :p

Thanks

Chen
04 Dec 2001, 14:05
Hooper, I really appreciate all your help and feedback. :)
Do you happen to have ICQ? If so, please contact me when you can. My number is listed in my profile.

Another change I plan to do is separating the custom templates and original templates in the selecting box.
Also in that area, I would like to group templates by their groups as they are listed in the Admin CP temlpates page.
I'll mess around with the idea a bit later and see what I can come up with.

Hooper I would really like to address all your ideas, but it's a bit hard for me to express what I think in English. :) :o
If we can talk in real time (ICQ or IRC) it would be great.

Hooper
04 Dec 2001, 14:25
OkeyDokey.

142002484

I'm live.

DelusionalMind
29 Dec 2001, 08:17
/me rushes to install

you rule dude!!! :)

Hooper
29 Dec 2001, 14:55
This has now been released as TBS (template backup system). I would download the hack from that thread. I don't know how updated this thread is.

TheComputerGuy
31 Dec 2001, 16:46
Works for WEb+++++ GREAT!!!

Lucky
03 Jan 2002, 09:14
Isn't this the same one as your other called Template Backup System?