PDA

View Full Version : Integration with vBulletin - Smarty Integration With Vbulletin - BETA


Jafo232
02-25-2008, 10:00 PM
This modification will allow you to use Smarty (http://www.smarty.net/) tags in your Vbulletin templates and even allow you to write PHP code in your templates.

I have tested this for the last 3-4 months before I posted it here and am pretty confident that it is all working properly but it should be fully tested on your site before released into production. I am still considering it BETA software.

This does require one small source code edit and there really is no way around it that I can find. There is no hook in the fetch_template() function at this time, so it is required.

After you install the modification, you can enter tags like this in your templates:

<%

## Whatever smarty code you want

%>


Or for PHP:


<%php%>
echo "Hello World! The timestamp for now is " . TIMENOW;
<%/php%>



If you find this useful, please:

Click Install (https://vborg.vbsupport.ru/vborg_miscactions.php?do=installhack&threadid=171502)

Brought to you by WorldWideCreations.com (http://www.worldwidecreations.com).

TTG
02-26-2008, 06:02 PM
Great news .. this could help designers produce more interesting themes / skins.

Jafo232
02-27-2008, 01:19 AM
Using smarty conditionals will definitely make things easier that is for sure..

Jon_Simmonds
02-27-2008, 04:17 PM
Have used smarty with some CMS's in the past, and they did prove usefull for some things will have a play on my test server with this

Jafo232
02-27-2008, 04:44 PM
Yeah, I would like to get some feedback on how this is all working for you..

goyo
02-27-2008, 11:00 PM
Smarty - to my knowledge - is the best and most flexible PHP template system. I love it.

Is there anybody who have experience with server performance when running this add-on in vB ?

Jafo232
02-28-2008, 01:22 AM
In my tests, I found it hardly noticeable. It will not improve performance as templates are still evaluated by Vbulletin. It would IMO although help performance if plugins were built around it. You would really not need the plugin system as we know it with this method as you could execute PHP right in the templates (ideally, with includes).

Also, in custom templates, you could in essence eliminate the need for bit templates as Smarty opens up loops which are not available in Vbulletin template conditionals.

alessai
02-28-2008, 07:03 PM
hey didnt work for me please help

what i had from the test is :
#######START CODE echo "Hello World! The timestamp for now is " . TIMENOW;
and i really need php

Jafo232
02-28-2008, 07:23 PM
Did you edit the functions.php file as laid out in the readme?

alessai
02-29-2008, 11:51 AM
yes i did

the file functions.php is in this path right??? /public_html/vb/includes

if ($vbulletin->options['addtemplatename'] AND $gethtmlcomments)
{
$templatename = preg_replace('#[^a-z0-9_]#i', '', $templatename);
return "<!-- BEGIN TEMPLATE: $templatename -->\n$template\n<!-- END TEMPLATE: $templatename -->";
}############### SMARTY

global $smarty, $tempusagecache;
if (is_object($smarty)) {
$vbulletin->temp_output = $template;
$template = $smarty->fetch('db:'. $templatename . '');
}

############### /SMARTY

return $template;
}

Jafo232
02-29-2008, 01:24 PM
Ok, and I assume you uploaded the files to their proper places, and set the directory permissions on the templates_c folder to 777?

Could you paste the code exactly as you put it in the template here (not the entire template please).

alessai
02-29-2008, 02:04 PM
yup uploaded templates_c and smarty inside the forum folder (vb) and i did set the permissions to 777
the code is

<%php%>
echo "Hello World! The timestamp for now is " . TIMENOW;
<%/php%>

Jafo232
02-29-2008, 02:27 PM
Sorry so many questions, but you did install the product file too right? And you have plugins turned on in your vbulletin options?

alessai
02-29-2008, 02:52 PM
yes its activatied

p.s. ask as much as u want i really want the php thing works

GCC LLC
02-29-2008, 04:10 PM
Have you had any experience using this on a load balanced server setup? I have 2 web front end servers and a shared (can use either CIFS or NFS) filesystem but when I enable this plugin, the servers all seem to slow down quite a bit. Do you know if I absolutely need to have the templates_c directory shared between all web servers? It seems that when smarty compiles to a remote filesystem that is where the slowdown occurs. I know this isn't a problem related specifically to your plugin, but thought I'd ask here anyway. BTW, my link between servers is all at 100mbps so there is plenty of bandwidth there to take care of things, but I may be limited by either the NFS or the CIFS services throughput. Your thoughts?

Jafo232
02-29-2008, 04:45 PM
yes its activatied

p.s. ask as much as u want i really want the php thing works

Look in your templates_c directory, are there any files in there other than index.html?

Jafo232
02-29-2008, 04:51 PM
Have you had any experience using this on a load balanced server setup? I have 2 web front end servers and a shared (can use either CIFS or NFS) filesystem but when I enable this plugin, the servers all seem to slow down quite a bit. Do you know if I absolutely need to have the templates_c directory shared between all web servers? It seems that when smarty compiles to a remote filesystem that is where the slowdown occurs. I know this isn't a problem related specifically to your plugin, but thought I'd ask here anyway. BTW, my link between servers is all at 100mbps so there is plenty of bandwidth there to take care of things, but I may be limited by either the NFS or the CIFS services throughput. Your thoughts?

Hmm, probably more of a Smarty question. I am not very experienced in the load balancing area but if you want to, you can try using a local directory for the templates_c. You would have to edit the plugin code. The plugin named "Start Up Smarty", find:

$smarty->compile_dir = DIR . '/templates_c';

You can change that to whatever you wish, example:

$smarty->compile_dir = '/some/other/path/onyour/server';

Just make sure the directory is writable.

alessai
02-29-2008, 05:24 PM
i found :
%%1E^1E8^1E8F45E3%%db%3Anewpost_quote.php
%%40^403^40326BD9%%db%3Aeditor_jsoptions_size.php
%%67^676^67664761%%db%3Aeditor_jsoptions_font.php

and no index file

Jafo232
02-29-2008, 06:17 PM
Hmm, then it is processing it..

Can you put that PHP code in the header template and confirm it still isn't working?

alessai
03-01-2008, 08:40 AM
still doesnt work,,,,
i use 3.6.8,,, is it possibe that the server disabled some things that affecting the addon ? or another addon ?

Jafo232
03-03-2008, 06:36 PM
I cannot think of any reason why it would not work on your server at this point. If you have the product installed, and have edited and saved functions.php, I cannot think of any reason why it is not working.

If you have a cache of some type installed on VB, you may want to try disabling it.

Reeve of shinra
03-03-2008, 07:23 PM
i dont have much experience with the smarty template system but this is deffinitely a unique mod and gets a big thumbs up and a MOTM nod. :)

Jafo232
03-04-2008, 01:16 PM
Thanks, I know this won't be a huge plugin for the masses, but I hope power users will understand the implications of it. Thanks again.

Jafo232
03-27-2008, 02:09 PM
alessai, any luck?

Marco van Herwaarden
03-27-2008, 03:40 PM
Just a note: The default vBulletin template system does not allow including PHP for security reasons (except a very few predefined functions that can be used in conditionals). Allowing PHP in templates will reduce security!

Jafo232
03-27-2008, 04:11 PM
I do not see how including PHP in templates will reduce security any more than allowing javascript in templates..

Jafo232
03-30-2008, 04:26 AM
I should also add, that if the PHP really bothers you, you can turn it off in Smarty.

mySaowt
04-17-2008, 08:40 PM
Great add-on for sure. I started a simpler version to re-create another version of the archive using Smarty caching. I will play around this one and see.

Jafo232
04-21-2008, 11:46 AM
Let me know how it turns out for ya.