PDA

View Full Version : few questions about templates


pawel.kudzia
11 Dec 2009, 12:53
hello,

what is the best-practice for writing new templates for custom pages?

i've followed this (http://www.vbulletin.org/forum/showthread.php?t=228112) tutorial and have no problem creating custom pages. but work with the built-in adminapc's template editor is not very handy, there is a lot of changing/saving/reloading/finding the right place in template again and again. can i - during design time - store template in a regular file?

also - where can i find tutorial how to bundle few custom templates, few custom .php files and some plugins as one product that can be easily exported / installed on other forum?

i'm using vbulletin 4beta5. thanks in advance for your help!

Lynne
11 Dec 2009, 15:34
I usually write my template out in a text editor first before copy/pasting it into the template form.

There aren't any tutorials on how to bundle them. Basically, when you create your mod in the admincp, always make sure you select the product when creating new templates, plugins, options, phrases, *whatever* and then they should all get exported when you export the product.

pawel.kudzia
11 Dec 2009, 15:47
hi Lynne

thanks a lot for your answers.
I usually write my template out in a text editor first before copy/pasting it into the template form.

yeah - that's doable but still a lot of switching forth and back. but apparently it's not just me with that problem.


There aren't any tutorials on how to bundle them. Basically, when you create your mod in the admincp, always make sure you select the product when creating new templates, plugins, options, phrases, *whatever* and then they should all get exported when you export the product.

great.. i did not thought about that. can i bundle also custom files [ for instance stand-alone php scripts or js'es ] into a product?

thanks!

Lynne
11 Dec 2009, 16:16
You might want to download a mod that comes with files and see how they did it. Usually, you get a zip file when you download a mod. Open the zip file and you get something like this:

- install.txt - the install instructions
- product-mod.xml - the product
- upload - just a folder
-- newfile.php - a file to upload in the main forum
-- images - an image folder
--- misc - a misc folder in the image folder
---- newimage.jpg - an image to upload in the images/misc folder
---- newimage2.jpg - another image to upload in the images/misc folder

pawel.kudzia
11 Dec 2009, 16:21
thanks! i thought it's possible to include also additional files [ php/js ] in product-mod.xml

Lynne
11 Dec 2009, 16:41
No, you can't include actual files in the .xml file.

pawel.kudzia
11 Dec 2009, 18:44
ok. so i will answer myself, at least partially.

vision of using built-in editor upset me so i've looked into the code and figured out that [only for development time; not for production!] i can load templates from files. here is how:

#1 create sample page as described at http://www.vbulletin.org/forum/showthread.php?t=228112

#2 modify end of the php file

$templater = vB_Template::create('TEST');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
// here come the changes:
require_once('includes/adminfunctions_template.php');
$vbulletin->templatecache[$templater->get_template_name()] = compile_template(file_get_contents ( './myTemplate.html' ));
// and last line remains unchanged
print_output($templater->render());


#3 add template as usual in adminCP, but store it's content also in ./myTemplate.html . if you need to do quick update - just modify that file.

this seems to work fine for me.. under vB4b5 at least.