View previous topic :: View next topic |
Author |
Message |
Lord Yggdrasill Smarty Rookie
Joined: 31 Mar 2012 Posts: 21
|
Posted: Fri Nov 23, 2012 11:27 am Post subject: Smarty shows blank page, even var_dump() wont work... |
|
|
Well I am trying to set up smarty template system for my script, but it looks like I am not doing it right. The biggest issue is that I cannot debug at all, since the page renders all blank.
Even var_dump() on smarty vars do not return any value, the page is still as white as a paper. Interestingly, if I put var_dump() right before the line that instantiating a smarty object, it works and shows some information. As soon as I move past the line called $this->template = new Smarty;, everything turns blank.
I dont understand why, does Smarty suppress all error reporting by default? If so, how can I enable it so I can finally figure out what goes wrong? Please help if you can, sorry... |
|
Back to top |
|
n0aX Smarty Rookie
Joined: 24 Jan 2011 Posts: 22
|
Posted: Fri Nov 23, 2012 1:53 pm Post subject: |
|
|
Code: | ini_set("display_errors", "on");
error_reporting(E_ALL ^ E_NOTICE); |
write those in your php file before smarty object. that may show up what the problem is. |
|
Back to top |
|
Lord Yggdrasill Smarty Rookie
Joined: 31 Mar 2012 Posts: 21
|
Posted: Fri Nov 23, 2012 2:22 pm Post subject: |
|
|
n0aX wrote: | Code: | ini_set("display_errors", "on");
error_reporting(E_ALL ^ E_NOTICE); |
write those in your php file before smarty object. that may show up what the problem is. |
Well it does not seem to be working, still blank page... In fact I sorta found out that smarty blank page with no errors usually is caused by php errors, but theres no way to debug when I do not know what it is.
To provide with more details... My script has a system wrapper object that encloses all other core objects such as database, cookie, session, currentuser, input and template. The template property of the system is a smarty object, which is defined in a way like this:
Code: |
class System{
public $db;
public $cookie;
public $session;
public $currentuser;
public $input;
public $template;
......
public function getTemplate(){
$templatedir = ROOT.SCRIPTPATH."/inc/smarty/Smarty.class.php";
require $templatedir;
return new Smarty;
}
}
|
Interestingly, when I use var_dump($templatedir) right below the line it is defined, the page displays the value for $templatedir. But if I move it down below the include/require line, even var_dump($templatedir) stops working.
It does seem to me that Smarty is blocking the error from being shown, is there a way to prevent this? And do you think the error is caused by the path Smarty file is located? Come to think about it, smarty's path is root/scriptpath/inc/smarty/, while the other folders such as cache, configs, templates and templates_c are placed in root/scriptpath/. Is this a, problem? |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Fri Nov 23, 2012 7:00 pm Post subject: |
|
|
Have you the checked the php_error.log file for error messages? |
|
Back to top |
|
Lord Yggdrasill Smarty Rookie
Joined: 31 Mar 2012 Posts: 21
|
Posted: Fri Nov 23, 2012 9:23 pm Post subject: |
|
|
U.Tews wrote: | Have you the checked the php_error.log file for error messages? |
Of course I did, error_log file did not record anything. |
|
Back to top |
|
Lord Yggdrasill Smarty Rookie
Joined: 31 Mar 2012 Posts: 21
|
Posted: Fri Nov 23, 2012 11:38 pm Post subject: |
|
|
I contacted my host and they found something like this:
Code: |
ALERT - Include filename ('******') is an URL that is not allowed (attacker '193.178.250.242', file '******', line 321)
|
Its kinda weird, the file inclusion was blocked? Is this smarty's doing or that my server caused the problem? Anyone know how to fix it?
Edit: Fixed this by using relative path rather than the actual http://www path. I have another problem though, its about caching. What is the best way to optimize cache? Right now if I enable caching, all pages show up as the same page from the very first one I visit. Strange. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
|
Back to top |
|
Lord Yggdrasill Smarty Rookie
Joined: 31 Mar 2012 Posts: 21
|
Posted: Mon Nov 26, 2012 5:35 am Post subject: |
|
|
Thanks a lot, I think I've got the idea of how to use Cache. I set the cache lifetime to 1 sec and it works out well. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Nov 26, 2012 7:30 pm Post subject: |
|
|
Setting the cache_lifetime = 1 does not solve the general problem and does create overhead because it is likely that on every page call the cache has to be refreshed.
As long as you are not able to work with some unique cache_id for different content being displayed with the same template you should not eable caching. |
|
Back to top |
|
|