Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Is it me or the f.. manual?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
CirTap
Smarty Pro


Joined: 04 Jun 2003
Posts: 106

PostPosted: Sun Aug 03, 2003 12:42 am    Post subject: Is it me or the f.. manual? Reply with quote

Hi y'all,
I got frustrated by this Sad
Quote:
Warning: Smarty error: unable to read template resource: "index.html"
in /my/scriptbase/include/lib/Smarty/Smarty.class.php on line 1042


"index.html" is supposed to be {included}ed from one of the directories in $secure_dir. The manuals states:
Quote:
$secure_dir This is an array of all local directories that are considered secure. {include} and {fetch} use this when security is enabled.

Being one of the few humans on this planet, that fo RTFM, this sentence means to me that I only need to provide the filename, no path, and that Smarty will "look" in all directories to find the file. I also found a matching loop in the code, that checks for the file, but for some reason this:
{include file='index.html'}
does not work. At least I get the filename, and not the usual "unknow function ()" nonsense.

Although Smarty "insists" it cannot load the file, this little "hoock" I added into the parse_template function to write some global array with all files that come along (so I can find out ehat unknow function is), proof something else: This spy-array contains the "index.html" file at the correct position of my template-chain:
Code:
[page_default.phtml] => /some-cache-path/page_default.phtml.php
[meta.phtml] => /some-cache-path/meta.phtml.php
[styles.phtml] => /some-cache-path/styles.phtml.php
[scripts.phtml] => /some-cache-path/scripts.phtml.php
[banner.phtml] => /some-cache-pathbanner.phtml.php
[navtop.phtml] => /some-cache-path/navtop.phtml.php
[navleft.phtml] => /some-cache-path/navleft.phtml.php
[B][index.html] => /some-cache-path/index.html.php [/B]
[footer.phtml] => /some-cache-path/footer.phtml.php


After a while I did provide the full qualified path to 'index.html', and it worked.

WHY?

Can someone please explain this odd behavior or is it another annoying thing with the manual?

Thanx,
CirTap
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sun Aug 03, 2003 1:14 am    Post subject: Re: Is it me or the f.. manual? Reply with quote

CirTap wrote:

The manuals states:
Quote:
$secure_dir This is an array of all local directories that are considered secure. {include} and {fetch} use this when security is enabled.

Being one of the few humans on this planet, that fo RTFM, this sentence means to me that I only need to provide the filename, no path, and that Smarty will "look" in all directories to find the file.


no, smarty uses the same mechanism to find a file regardless of the security-settings. but with $security=true it is additionally checked if the directory where the file is in is also in the $secure_dir-array.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CirTap
Smarty Pro


Joined: 04 Jun 2003
Posts: 106

PostPosted: Sun Aug 03, 2003 5:27 pm    Post subject: Reply with quote

re messju,

(ich blix immer noch nich, sorry <g>)

so does this mean, that despite I tell Smarty that my "content directory" is "secure" and therefor available in $secure_dir, I still have to use
'file:/some/path/considered/secure/but/who/cares/index.html'
with {include} ?

I don't want PHP to "passthru" every dump .html file just to have it assigned to a Smarty var, that'd be total nonsense especially that Smarty has all the routines built in to do this. I also don't see the "need" to use fetch(), which would be the same.
The people writing the content can save their 'static' files in a separate folder, which is at someplace outside the docroot and outside $template_dir. Nevertheless, they have a list of "common" Smarty vars and blocks they can put in their files, so the 'static' content files are by means templates, and get cached, which is what I want, but I cannot put the in THE $template_dir.

In case I missed some setting, any idea how I can make it look in my content_path, too? -- or do I really have to do this:
$Page->assign('Content', $Page->fetch('/pages/de/index.html') );

t.i.a. 4 any ideas.

CirTap
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sun Aug 03, 2003 7:08 pm    Post subject: Reply with quote

CirTap wrote:
so does this mean, that despite I tell Smarty that my "content directory" is "secure" and therefor available in $secure_dir, I still have to use
'file:/some/path/considered/secure/but/who/cares/index.html'
with {include} ?


simple: yes.

less simple: smarty is designed to have *one* template_dir. the template_dir can have many subdirectories but there is still one root. if you want to {include} from other places and don't want to specify the full path everytime, you can consider writing a simple custom-plugin that fetches and returns the template-contents (see: http://smarty.php.net/manual/en/plugins.functions.php ) or write a custom resource that does the job (see: http://smarty.php.net/manual/en/templates.from.elsewhere.php ).

HTH
messju
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CirTap
Smarty Pro


Joined: 04 Jun 2003
Posts: 106

PostPosted: Sun Aug 03, 2003 10:16 pm    Post subject: Reply with quote

hmm... didn't thought of another "ressource type", but for the moment I don't want to mess around with expirationtimes and stuff.
I guess I can have a more simple workaround using subdirectories:
Code:
/templates/             the "system templates"
/templates/pages/   "new" FTP-home for content writers

so all I have to do is change the "content files path" in my prepend file.
I can live with that Cool

Thanx a lot messju, for the "inspiration" Smile

Have fun,
CirTap

UPDATE: it worked Smile
It took me a ~ 30 minutes to fix (and find) all "path dependancies" and make some changes to the main script.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP