Sugumar Venkatesan
Sugumar Venkatesan

Reputation: 4028

My smarty template is not displaying

I am using Php Smarty on Linux.

I have a line in my Php file:

$phpsmart->display("pagetemplate.tpl");

This line is supposed to display pagetemplate.tpl. It doesn't.

Upvotes: 0

Views: 3607

Answers (2)

Sugumar Venkatesan
Sugumar Venkatesan

Reputation: 4028

It doesn't display a tpl file even after changing the file permissions and ownership of a file.

for people who are having problem like this.

1) chmod -R 755 /var/www -> This will give read write permission to the owner and other for the group( the owner belongs to), and others the permission in read and execute. and this is assigned recursively so all your files and directories inside www will also be having the same permissions

2) chown -R apache:apache /var/www ->This will give make apache owner of www and including files. This is also applied recursively.

3)your website owner needs write permission to template_c file so check using ls -altr to see whether it has given the write permission, if write is like 755(rwxr-xr-x) and still not working change it to 777 (remember chmod). also check the cache folder..

4) If still it's not working may be selinux is protecting write access to your template_c file. so for this you need the following command

setsebool -P httpd_unified=1   -> This will disable selilnux for apache httpd. 

Enjoy!

Upvotes: -1

Progrock
Progrock

Reputation: 7485

Enable errors, or check your logs. The most likely thing is that you haven't set up writeable directories needed by smarty.

I just installed smarty with composer:

$ composer.phar require smarty/smarty

And tried the demo:

( ! ) Fatal error: Uncaught --> Smarty: unable to write file ./templates_c/wrt56681191371d80_85949214 <-- thrown in /var/www/smarty/vendor/smarty/smarty/libs/sysplugins/smarty_internal_write_file.php on line 46

I then created that 'template_c' folder, and made it writeable by the web server.

( ! ) Fatal error: Uncaught --> Smarty: unable to write file ./cache/wrt566812bd6f7b08_17223124 <-- thrown in /var/www/smarty/vendor/smarty/smarty/libs/sysplugins/smarty_internal_write_file.php on line 46

I then created the 'cache' folder, and made it writeable by the web server.

The demo then worked.

See the quick install.

Upvotes: 6

Related Questions