This is an old revision of the document!


Uninitialized PHP variables in injected blocks

Problem: The footer template failed to output for SNS themes

Cause: The customized themes references user initialized global PHP variables in injected blocks. When those ESI blocks render, null pointer errors occurs as those variables has been initialized earlier but the injected block has no way of recognizing them. In SNS case here it is due to the variable “$var_snstheme” actually being initialized in the header block.

Solution: Find the code where this variable is initialized, copy this logic to the template of the injected block. For example, adding the following 2 lines:

global $var_snstheme;
if (empty($var_snstheme)) {
    include (dirname(dirname(__FILE__)).'/sns/sns.php');
}

Similarly, for SM themes (such as sm-maxshop yttheme):

if (empty($var_yttheme)) {
        include (dirname(dirname(__FILE__)).'/sm/yt_prepar.php');
}

Alternative Solution: You can remove footer block injection. This however will slow down page loading time as well as increase cache size and is hence not recommended.

  • Admin
  • Last modified: 2016/05/09 15:17
  • by Long Hu