View previous topic :: View next topic |
Author |
Message |
yurikoma Smarty Rookie
Joined: 20 Sep 2014 Posts: 5
|
Posted: Sat Sep 20, 2014 7:43 pm Post subject: Trouble With .php pages in subdirectorys (SOLVED) |
|
|
I have been stuck trying to get this to work for a few days now, while also trying to find the answer online.
I have all my main .php files located at the root of my website.
(these all work fine.)
But I also have a subdirectory for my news pages.
(so my website looks something like:
/News/2014/8/newsentry.php
/smarty/
/styles/
/index.php
(there is more in there, but that's the basics.
anyway the problem is that newsentry.php comes out blank when it is located in this location and not at the root.
I have been guessing it is a problem finding Smarty.class.php and or the templates, but i have not been able to work out how to set them correctly for subdirectorys
Code: | <?php
// put full path to Smarty.class.php
require('./smarty/libs/Smarty.class.php');
$smarty = new Smarty();
$smarty->setTemplateDir('./smarty/templates');
$smarty->setCompileDir('./smarty/templates_c');
$smarty->setCacheDir('./smarty/cache');
$smarty->setConfigDir('./smarty/configs');
$smarty->assign('title', 'Index');
$smarty->assign('style', 'href="Styles/Default.css"');
$smarty->display('index.tpl');
?> |
this is my index.php. how should it be changed to get it to work with newsentry.php
Last edited by yurikoma on Fri Sep 26, 2014 10:07 pm; edited 1 time in total |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sat Sep 20, 2014 7:48 pm Post subject: |
|
|
Code: | <?php
define('SMARTY_DIR', '/full/system/path/to/smarty/');
// put full path to Smarty.class.php
require(SMARTY_DIR . 'libs/Smarty.class.php');
$smarty = new Smarty();
$smarty->setTemplateDir(SMARTY_DIR . 'templates');
$smarty->setCompileDir(SMARTY_DIR . 'templates_c');
$smarty->setCacheDir(SMARTY_DIR . 'cache');
$smarty->setConfigDir(SMARTY_DIR . 'configs');
$smarty->assign('title', 'Index');
$smarty->assign('style', 'href="Styles/Default.css"');
$smarty->display('index.tpl');
?> |
You are using relative "." path names, and the paths differ. Try an absolute path name solution, such as the above. |
|
Back to top |
|
yurikoma Smarty Rookie
Joined: 20 Sep 2014 Posts: 5
|
Posted: Sat Sep 20, 2014 8:09 pm Post subject: |
|
|
mohrt wrote: |
You are using relative "." path names, and the paths differ. Try an absolute path name solution, such as the above. |
I have done this, the page is still not working, but am receiving the following error.
[20-Sep-2014 14:05:29] PHP Fatal error: require() [<a href='function.require'>function.require</a>]: Failed opening required '/public_html/smarty/libs/Smarty.class.php' (include_path='.:/usr/lib64/php:/usr/share/pear') in /home4/yurikom1/public_html/News/2014/8/Website_OverHaul.php on line 5
does that help at all?
Code: | [20-Sep-2014 14:20:24] PHP Warning: include_once(/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_data.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 91
[20-Sep-2014 14:20:24] PHP Warning: include_once() [<a href='function.include'>function.include</a>]: Failed opening '/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_data.php' for inclusion (include_path='.:/usr/lib64/php:/usr/share/pear') in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 91
[20-Sep-2014 14:20:24] PHP Warning: include_once(/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_templatebase.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 92
[20-Sep-2014 14:20:24] PHP Warning: include_once() [<a href='function.include'>function.include</a>]: Failed opening '/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_templatebase.php' for inclusion (include_path='.:/usr/lib64/php:/usr/share/pear') in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 92
[20-Sep-2014 14:20:24] PHP Warning: include_once(/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_template.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 93
[20-Sep-2014 14:20:24] PHP Warning: include_once() [<a href='function.include'>function.include</a>]: Failed opening '/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_template.php' for inclusion (include_path='.:/usr/lib64/php:/usr/share/pear') in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 93
[20-Sep-2014 14:20:24] PHP Warning: include_once(/home4/yurikom1/public_html/smarty/sysplugins/smarty_resource.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 94
[20-Sep-2014 14:20:24] PHP Warning: include_once() [<a href='function.include'>function.include</a>]: Failed opening '/home4/yurikom1/public_html/smarty/sysplugins/smarty_resource.php' for inclusion (include_path='.:/usr/lib64/php:/usr/share/pear') in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 94
[20-Sep-2014 14:20:24] PHP Warning: include_once(/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_resource_file.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 95
[20-Sep-2014 14:20:24] PHP Warning: include_once() [<a href='function.include'>function.include</a>]: Failed opening '/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_resource_file.php' for inclusion (include_path='.:/usr/lib64/php:/usr/share/pear') in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 95
[20-Sep-2014 14:20:24] PHP Warning: include_once(/home4/yurikom1/public_html/smarty/sysplugins/smarty_cacheresource.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 96
[20-Sep-2014 14:20:24] PHP Warning: include_once() [<a href='function.include'>function.include</a>]: Failed opening '/home4/yurikom1/public_html/smarty/sysplugins/smarty_cacheresource.php' for inclusion (include_path='.:/usr/lib64/php:/usr/share/pear') in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 96
[20-Sep-2014 14:20:24] PHP Warning: include_once(/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_cacheresource_file.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 97
[20-Sep-2014 14:20:24] PHP Warning: include_once() [<a href='function.include'>function.include</a>]: Failed opening '/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_cacheresource_file.php' for inclusion (include_path='.:/usr/lib64/php:/usr/share/pear') in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 97
[20-Sep-2014 14:20:24] PHP Warning: include() [<a href='function.include'>function.include</a>]: Failed opening '/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_templatebase.php' for inclusion (include_path='.:/usr/lib64/php:/usr/share/pear') in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 1672
[20-Sep-2014 14:20:24] PHP Fatal error: Class 'Smarty_Internal_TemplateBase' not found in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 104
[20-Sep-2014 14:20:33] PHP Warning: include_once(/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_data.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 91
[20-Sep-2014 14:20:33] PHP Warning: include_once() [<a href='function.include'>function.include</a>]: Failed opening '/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_data.php' for inclusion (include_path='.:/usr/lib64/php:/usr/share/pear') in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 91
[20-Sep-2014 14:20:33] PHP Warning: include_once(/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_templatebase.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 92
[20-Sep-2014 14:20:33] PHP Warning: include_once() [<a href='function.include'>function.include</a>]: Failed opening '/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_templatebase.php' for inclusion (include_path='.:/usr/lib64/php:/usr/share/pear') in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 92
[20-Sep-2014 14:20:33] PHP Warning: include_once(/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_template.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 93
[20-Sep-2014 14:20:33] PHP Warning: include_once() [<a href='function.include'>function.include</a>]: Failed opening '/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_template.php' for inclusion (include_path='.:/usr/lib64/php:/usr/share/pear') in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 93
[20-Sep-2014 14:20:33] PHP Warning: include_once(/home4/yurikom1/public_html/smarty/sysplugins/smarty_resource.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 94
[20-Sep-2014 14:20:33] PHP Warning: include_once() [<a href='function.include'>function.include</a>]: Failed opening '/home4/yurikom1/public_html/smarty/sysplugins/smarty_resource.php' for inclusion (include_path='.:/usr/lib64/php:/usr/share/pear') in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 94
[20-Sep-2014 14:20:33] PHP Warning: include_once(/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_resource_file.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 95
[20-Sep-2014 14:20:33] PHP Warning: include_once() [<a href='function.include'>function.include</a>]: Failed opening '/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_resource_file.php' for inclusion (include_path='.:/usr/lib64/php:/usr/share/pear') in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 95
[20-Sep-2014 14:20:33] PHP Warning: include_once(/home4/yurikom1/public_html/smarty/sysplugins/smarty_cacheresource.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 96
[20-Sep-2014 14:20:33] PHP Warning: include_once() [<a href='function.include'>function.include</a>]: Failed opening '/home4/yurikom1/public_html/smarty/sysplugins/smarty_cacheresource.php' for inclusion (include_path='.:/usr/lib64/php:/usr/share/pear') in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 96
[20-Sep-2014 14:20:33] PHP Warning: include_once(/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_cacheresource_file.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 97
[20-Sep-2014 14:20:33] PHP Warning: include_once() [<a href='function.include'>function.include</a>]: Failed opening '/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_cacheresource_file.php' for inclusion (include_path='.:/usr/lib64/php:/usr/share/pear') in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 97
[20-Sep-2014 14:20:33] PHP Warning: include() [<a href='function.include'>function.include</a>]: Failed opening '/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_templatebase.php' for inclusion (include_path='.:/usr/lib64/php:/usr/share/pear') in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 1672
[20-Sep-2014 14:20:33] PHP Fatal error: Class 'Smarty_Internal_TemplateBase' not found in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 104 |
|
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sun Sep 21, 2014 12:21 am Post subject: R to |
|
|
It looks like you set SMARTY_DIR to /public_html/smarty/ when it needs to be /home4/yurikom1/public_html/smarty/ (?) |
|
Back to top |
|
yurikoma Smarty Rookie
Joined: 20 Sep 2014 Posts: 5
|
Posted: Sun Sep 21, 2014 3:17 pm Post subject: Re: R to |
|
|
mohrt wrote: | It looks like you set SMARTY_DIR to /public_html/smarty/ when it needs to be /home4/yurikom1/public_html/smarty/ (?) |
I actually tried both. the block of errors was the result of setting it to /home4/yurikom1/public_html/smarty/ |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sun Sep 21, 2014 4:53 pm Post subject: |
|
|
did you install ALL of the smarty files from the distro?
example does:
/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_data.php
exist and readable by the web server user? |
|
Back to top |
|
yurikoma Smarty Rookie
Joined: 20 Sep 2014 Posts: 5
|
Posted: Fri Sep 26, 2014 5:35 am Post subject: |
|
|
mohrt wrote: | did you install ALL of the smarty files from the distro?
example does:
/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_data.php
exist and readable by the web server user? |
my sysplugins folder is located in smarty/libs/sysplugins
the file mentioned is also inside it. and the permissions are set to 644
NOTE: I pretty much moved the whole Smarty-3.1.19 folder from the zip and renamed it to smarty, so i am assuming all needed files are included.
everything else seems to work fine except absolute paths.
Sorry if I am missing something very obvious, this has been a very confusing problem for me. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Sep 26, 2014 6:27 pm Post subject: |
|
|
See the first line of that error:
Code: | [20-Sep-2014 14:20:24] PHP Warning: include_once(/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_data.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in /home4/yurikom1/public_html/smarty/libs/Smarty.class.php on line 91 |
So there is a discrepancy between those two paths:
Quote: | /home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_data.php
/home4/yurikom1/public_html/smarty/libs/Smarty.class.php |
So I'm guessing this does not exist:
/home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_data.php
And this does:
/home4/yurikom1/public_html/smarty/libs/sysplugins/smarty_internal_data.php |
|
Back to top |
|
yurikoma Smarty Rookie
Joined: 20 Sep 2014 Posts: 5
|
Posted: Fri Sep 26, 2014 10:06 pm Post subject: |
|
|
Thanks for pointing that out. I have now moved the folder into the location it is looking for.
at first the page didn't load and threw the error
Code: | [26-Sep-2014 15:17:43] PHP Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "/home4/yurikom1/public_html/smarty/templates/header.tpl" on line 4 "<title>{$title|default:'no title'}</title>" unknown modifier "default" <--
thrown in /home4/yurikom1/public_html/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 4 |
I found out i had two plugin folders so I replaced the first one with the one from smarty/libs that fixed the error above.
i also received an error with the date_format function inside my footer, but i fixed it by using the solution from http://www.smarty.net/forums/viewtopic.php?t=10632.
So now everything works, and it was a great learning experience. thanks for all the help |
|
Back to top |
|
|