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

Smarty shows blank page, even var_dump() wont work...

 
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
Lord Yggdrasill
Smarty Rookie


Joined: 31 Mar 2012
Posts: 21

PostPosted: Fri Nov 23, 2012 11:27 am    Post subject: Smarty shows blank page, even var_dump() wont work... Reply with quote

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
View user's profile Send private message
n0aX
Smarty Rookie


Joined: 24 Jan 2011
Posts: 22

PostPosted: Fri Nov 23, 2012 1:53 pm    Post subject: Reply with quote

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
View user's profile Send private message
Lord Yggdrasill
Smarty Rookie


Joined: 31 Mar 2012
Posts: 21

PostPosted: Fri Nov 23, 2012 2:22 pm    Post subject: Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Fri Nov 23, 2012 7:00 pm    Post subject: Reply with quote

Have you the checked the php_error.log file for error messages?
Back to top
View user's profile Send private message
Lord Yggdrasill
Smarty Rookie


Joined: 31 Mar 2012
Posts: 21

PostPosted: Fri Nov 23, 2012 9:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
Lord Yggdrasill
Smarty Rookie


Joined: 31 Mar 2012
Posts: 21

PostPosted: Fri Nov 23, 2012 11:38 pm    Post subject: Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sat Nov 24, 2012 5:42 am    Post subject: Reply with quote

If you enable caching Smarty stores the final rendered HTML of the page by the template name used in display() call.

If you want to cache different content using the same template (for example pages to display different products) you need to use unique cache_id's (in my example it could be the part number) when calling the page.
See http://www.smarty.net/docs/en/caching.tpl and http://www.smarty.net/docs/en/caching.multiple.caches.tpl

If only small parts of a template is dynamic you could just exclude parts of the template from caching. See http://www.smarty.net/docs/en/caching.cacheable.tpl#cacheability.variables
Back to top
View user's profile Send private message
Lord Yggdrasill
Smarty Rookie


Joined: 31 Mar 2012
Posts: 21

PostPosted: Mon Nov 26, 2012 5:35 am    Post subject: Reply with quote

U.Tews wrote:
If you enable caching Smarty stores the final rendered HTML of the page by the template name used in display() call.

If you want to cache different content using the same template (for example pages to display different products) you need to use unique cache_id's (in my example it could be the part number) when calling the page.
See http://www.smarty.net/docs/en/caching.tpl and http://www.smarty.net/docs/en/caching.multiple.caches.tpl

If only small parts of a template is dynamic you could just exclude parts of the template from caching. See http://www.smarty.net/docs/en/caching.cacheable.tpl#cacheability.variables


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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon Nov 26, 2012 7:30 pm    Post subject: Reply with quote

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
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