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

Post by launchcode »

It can be renamed to anything - so your guess is as good as mine. But looking for the wrong variable won't help, it's called: $config['tpl_cache_level'] - do a multi-file search for it?
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

Ok, will do.. Ok, i am at work now, and the setting of permissions seems to have solved most of my agony. Besides one little thing of not being able to update my header.tpl, i can fully make use of the templating system now it seems.

Although with being able to use the templates, I have run into another interesting occurance. Now, whenever I update a template. I will load it in explorer, and get this error:
Image

But with a refresh it is gone, and the page is fine. My boss was wondering why we get error on first occorance of load, and if whenenver any template is updated we will have to see an error on first load.
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

Smarty has tried to change the permissions on a file which has failed and raised that warning. Look in the Smarty documentation to find out how to stop it from performing a chmod.
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

I see, its trying to change it here:


function _write_file($filename, $contents, $create_dirs = false)
{
if ($create_dirs)
$this->_create_dir_structure(dirname($filename));

if (!($fd = @fopen($filename, 'w'))) {
$this->trigger_error("problem writing '$filename.'");
return false;
}

// flock doesn't seem to work on several windows platforms (98, NT4, NT5, ?),
// so we'll not use it at all in windows.

if ( strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' || (flock($fd, LOCK_EX)) ) {
fwrite( $fd, $contents );
fclose($fd);
chmod($filename, 0644); <!--- Right here-- --->
}

return true;
}


How do I stop this?
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

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

Post by NewfieBilko »

Also, here is my directory structure:
Image

Any ideas where that 'tpl_cache_level' variable might reside? :) thx
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

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

Post by NewfieBilko »

LOL no i shouldn't comment it out though should I? Its a function, so obviously it is getting called from somewherre...../


Ignore, i already commented it out lol
Last edited by NewfieBilko on Mon Jun 07, 2004 8:31 am, edited 1 time in total.
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

may need the function for something else... hmm, wheres it calling to that _write_file function i wonder...hmmm
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

Ok, as u can see here I commented out just the chmod. It seems now that it works!! :P

I just hope that taking out that chmod, will not effect anything down the road.

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

Post by NewfieBilko »

Ok guys..

Everything seems fine.. I can update all templates. EXCEPT ONE :oops:

:(

The header.tpl. When i update this template, which has all the info that goes at the top of my page <html> through <body>, it gives me this error:

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

Post by NewfieBilko »

and here is the refering code:
Last edited by NewfieBilko on Mon Jun 07, 2004 8:50 am, edited 1 time in total.
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

and the code for header:

Image

I was thinking maybe that my javascript is fooling this up.
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

Ok, once I took out the java, it seems like it fixes, and I can now edit my header.tpl and it will be REFLECTED and changed. Guess smarty doesn't like having java IF's in the templates.. In order to load this java, in which level do i want it?
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

It might not be the Javascript - it might just be what you're using as the Smarty delimeter, it can use <!-- which might be why the JS is confusing it. Delimeter = telling Smarty when to jump into/out of PHP mode, so obviously not something you'd want to do if you're about to feed it a load of JS.
Post Reply