View previous topic :: View next topic |
Author |
Message |
mgm_03 Smarty Rookie
Joined: 07 Dec 2004 Posts: 23
|
Posted: Tue Dec 07, 2004 10:01 pm Post subject: MacOSX : unable to read resource: index.tpl |
|
|
Hopefully the administrators' patience has not run dry...I've heard great things about Smarty and want to use it on my next client project. I'm not a php noobie but not a guru either. Using Mac OS X / php4.34 / apache 1.3.
The Smarty directory is located in the include_path which is .:/usr/local/php/lib/php. Document root is : /Library/WebServer/Documents
Code: |
require('Smarty/Smarty.class.php');
$smarty = new Smarty; // running this generates no errors.
$smarty ->template_dir = '/Library/WebServer/Documents/Majestic/smarty/majestic/templates/';
$smarty->compile_dir = '/Library/WebServer/Documents/Majestic/smarty/majestic/templates_c/';
$smarty->config_dir = '/Library/WebServer/Documents/Majestic/smarty/majestic/configs/';
$smarty->compile_dir = '/Library/WebServer/Documents/Majestic/smarty/majestic/cache/';
$smarty-> assign('name', 'Mark');
$smarty->display('index.tpl');
|
Questions:
Am I correctly identifying the absolute paths?
Majestic is a website I am developing on my notebook. 'smarty' contains the 4 directories.
I can't seem to set the user to 'www' for those 4 folders. That user is not available to me when I try to change to a different user.
www:*:70:70::0:0:World Wide Web Server:/Library/WebServer:/dev/null
drwxr-xr-x 8 markmara admin 272 Dec 7 15:04 .
drwxr-xr-x 3 markmara admin 102 Dec 7 13:36 ..
drwxr-xr-x 2 nobody nobody 68 Dec 7 13:42 cache
drwxr-xr-x 2 nobody nobody 68 Dec 7 13:42 config
drwxr-xr-x 2 nobody nobody 68 Dec 7 13:42 templates
drwxr-xr-x 2 nobody nobody 68 Dec 7 13:41 templates_c
Any tips/advice are greatly appreciated. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Dec 07, 2004 11:10 pm Post subject: |
|
|
I have an OS X box here, I can change ownership of files to www:
chmod www [filename]
What do you get when you id the user? Here is what I see:
[root@foo mohrt]# id www
uid=70(www) gid=70(www) groups=70(www) |
|
Back to top |
|
mgm_03 Smarty Rookie
Joined: 07 Dec 2004 Posts: 23
|
Posted: Tue Dec 07, 2004 11:29 pm Post subject: |
|
|
Thanks for the prompt reply.
I have the same info for id www
I was able to chown the 4 directories to www:www (user:group). I had to log in as root...apparently, only root can change ownership. Prior to that I was trying do it through Aqua.
drwxr-xr-x 2 www www 68 Dec 7 13:42 cache
drwxr-xr-x 2 www www 68 Dec 7 13:42 config
drwxr-xr-x 2 www www 68 Dec 7 13:42 templates
drwxr-xr-x 2 www www 68 Dec 7 13:41 templates_c
But...still getting :
Warning: Smarty error: unable to read resource: "index.tpl" in /usr/local/php/lib/php/Smarty/Smarty.class.php on line 1084 ok
I feel like an idiot. |
|
Back to top |
|
mgm_03 Smarty Rookie
Joined: 07 Dec 2004 Posts: 23
|
Posted: Wed Dec 08, 2004 12:21 am Post subject: |
|
|
In an effort to solve this problem, I've been going back and forth to the documentation and noticed a peculiar comment :
Quote: | We need to create the index.tpl file that Smarty will load. This will be located in your $template_dir. |
After that the doc refers to index.php.
Is this a typo?
Do I need to create an index.tpl file or index.php? And, what goes in it? |
|
Back to top |
|
mgm_03 Smarty Rookie
Joined: 07 Dec 2004 Posts: 23
|
Posted: Wed Dec 08, 2004 12:27 am Post subject: |
|
|
OK...It's official now: I AM A GENUINE IDIOT.
I did not have an index.tpl file in the templates directory. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Dec 08, 2004 2:43 am Post subject: |
|
|
mgm_03 wrote: | I was able to chown the 4 directories to www:www (user:group). I had to log in as root...apparently, only root can change ownership. Prior to that I was trying do it through Aqua. |
lol, I've had my head buried in the unix sand for so many years that it didn't even occur to me that you might be trying this as someone other than root. Yes, only the root user (or user with root privs) can change the ownership of a file, which makes perfect sense if you think about it |
|
Back to top |
|
mgm_03 Smarty Rookie
Joined: 07 Dec 2004 Posts: 23
|
Posted: Wed Dec 08, 2004 3:44 am Post subject: |
|
|
I envy you...unix just isn't something I'm involved with on a regular basis...so, it's always a mystery. I know it's better to work from the command line but with all the web stuff I need to learn, getting in a shell isn't high on the priority list.
Something that I don't understand...from the doc:
Quote: | Be sure you know the location of your web server document root. In our example, the document root is "/web/www.mydomain.com/docs/". The Smarty directories are only accessed by the Smarty library and never accessed directly by the web browser. Therefore to avoid any security concerns, it is recommended to place these directories outside of the document root. |
Based on my current configuration, my folders are 'in' the document root...but doing that is discouraged, right?
Suggestion: I may or may not be the only person who didn't catch on to the fact that I needed to create an empty index.tpl file, but it wouldn't hurt to make that super-clear in the documentation. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Dec 08, 2004 4:40 am Post subject: |
|
|
yes, the smarty directories should be outside of the document root if possible.
As for the documentation:
Quote: | We need to create the index.tpl file that Smarty will load. This will be located in your $template_dir. |
Then it goes on to edit the file and show its contents. Not clear enough? |
|
Back to top |
|
mgm_03 Smarty Rookie
Joined: 07 Dec 2004 Posts: 23
|
Posted: Wed Dec 08, 2004 5:05 am Post subject: |
|
|
you're right...it's clear...remember that part about being an idiot? |
|
Back to top |
|
|