Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Object scope in block

 
Post new topic   Reply to topic    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
lsces
Smarty Rookie


Joined: 03 Dec 2011
Posts: 8

PostPosted: Sun Feb 07, 2016 1:41 pm    Post subject: Object scope in block Reply with quote

Another probably PHP related problem. Having got everything moved over to PHP7, updated all the third party stuff, and even updated all the SmartyBC stuff to eliminate the residual Smarty2 code I had almost everything working ... except ...

http://php7.lsces.org.uk/ is the test etup, and is displaying content in the right hand modules, but when I first got things running they were blank.

The hacked code below is working, but the problem eems to be with the 'scope' of $gBitSmarty which is what should be supplied in &$gBitX but 'modInfo' while being displayed in the getTemplateVars on both scopes, only doing the assign to the global version results in the fetch being populated.

function smarty_block_bitmodule( $pParams, $pContent, &$gBitX) {
global $gBitSmarty;
if( empty( $pContent )) {
return '';
} else {
$pParams['data'] = $pContent;
}
$pParams['name'] = preg_replace( "/[^a-zA-Z0-9\\-\\_]/", "", $pParams['name'] );
$gBitSmarty->assign( 'modInfo', $pParams );
// vd( $gBitSmarty->getTemplateVars() );
// vd($gBitX->getTemplateVars());
$module = $gBitX->fetch('bitpackage:themes/module.tpl');
// vd($module);
return $module;
}

Anybody got any idea where to look next? OTHER bocks are working fine, but are probably using display rather than fetch, so I suspect the problem is there somewhere.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Bugs 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