Page 1 of 4
Help: Smarty Templates/Boss needs answer tommorow :/
Posted: Sun Jun 06, 2004 6:45 pm
by NewfieBilko
Hi
Ok, Im a new employee with a development office. Anyway, the boss has gotten me to look highly into php and this new system, Smarty. im sure u've heard of it. It uses 2 directories, templates, and templates_c. In the root/ u have the .php's which will load a template from /templates/ to output the html code. The actual load on enduser screen seems to be the writen compiled file in the /templates_c/ which is the combination of the template and the php script. So. I am supposed to be able to change what the html comes out to be by editing the template. But everytime i do edit it in /templates/ it gives me an error, and it does not compile correctly to /templates_c/. In ordeer to have a working page with no error, i have to write to the /templates_c/ files and do most of my code on that, which is supposed to be writen from Smarty, not the admin. Any help? PELASE

My boss was like , ok research why this is happeneing and figure out if Smarty is a good system to use or too much work..
Posted: Sun Jun 06, 2004 7:18 pm
by launchcode
Well what sort of errors do you get if you modify the templates?
Posted: Sun Jun 06, 2004 8:11 pm
by NewfieBilko
I end up getting a weird error out of the Smarty.Class and it points to the .tpl (/template/) i was refering to..
Posted: Sun Jun 06, 2004 8:17 pm
by launchcode
Or.. more specifically.. what's the EXACT error you're getting? We cannot debug "weird".
Posted: Sun Jun 06, 2004 8:28 pm
by NewfieBilko
Here is an example:
The template file edited to show a new change to the output:
<br>
and here it is supposed to accept the change:

Posted: Sun Jun 06, 2004 8:32 pm
by NewfieBilko
And so now that error is there.
The only way i can clear that error is if i go in a manually re-save the compiled file in the /templates_c/, that "compiled" file is supposed to be writen from the template, but it seems my system does even look at the /templates/ and just takes whatevers in the already writen compiled directory and puts that out, ignoring my /templates/ unless the originaol have changed.
Posted: Sun Jun 06, 2004 8:37 pm
by launchcode
Your template_c directory doesn't have the correct permissions for Smarty to be able to generate the new script blocks. Change the directory settings.
Also, you can edit config.inc.php and change: $config['tpl_cache_level'] = 0;
Posted: Sun Jun 06, 2004 8:38 pm
by launchcode
After-thought: Changing the cache level will mean every hit to your site causes the template to be recalculated/built each time, which is an overhead you don't want on a busy site.
Posted: Sun Jun 06, 2004 8:44 pm
by NewfieBilko
Posted: Sun Jun 06, 2004 8:47 pm
by NewfieBilko
so u'd put the cache level to 1 to turn it on?
Posted: Sun Jun 06, 2004 8:48 pm
by launchcode
Nice screen shot, but did you not read a word of what I wrote? Smarty cannot change the file in the template_c directory because it doesn't have permissions to over-write the one that exists in there. This is a permissions issue and nothing more.
Posted: Sun Jun 06, 2004 8:49 pm
by launchcode
so u'd put the cache level to 1 to turn it on?
No, that's your whole problem - it is already set to 1 - but it cannot create the cache files (the contents of template_c) because it doesn't have write permissions on that directory.
Posted: Sun Jun 06, 2004 8:50 pm
by NewfieBilko
well what kinda permission do you suggest i give to the directory, it is already on modify for everyone...
how do i give smarty the write permissions?
also.. thanks by the way, and
uhh so smarty can't write a new compilation, but it will pick up/accept me changing the files in /templates_c/ and display those fine!?!?!
Posted: Sun Jun 06, 2004 8:52 pm
by launchcode
Try chmod 777 to start with and then work your way down from there making it more secure as you go. Or just set that cache level to 0. You don't need to do both.
Posted: Sun Jun 06, 2004 8:54 pm
by NewfieBilko
if my permissions where all fine and everything was working, what would changing cache from 1 to 0 do?
sorry, im a bit slow i guess