Help: Smarty Templates/Boss needs answer tommorow :/

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Help: Smarty Templates/Boss needs answer tommorow :/

Post 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..
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

Well what sort of errors do you get if you modify the templates?
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post 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..
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

Or.. more specifically.. what's the EXACT error you're getting? We cannot debug "weird".
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

Here is an example:

The template file edited to show a new change to the output:
Image

<br>
and here it is supposed to accept the change:
Image
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post 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.
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post 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;
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post 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.
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

Image
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

so u'd put the cache level to 1 to turn it on?
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post 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.
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post 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.
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post 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!?!?!
Last edited by NewfieBilko on Sun Jun 06, 2004 8:52 pm, edited 1 time in total.
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post 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.
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post 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
Post Reply