0

Hopefully someone can help me with this. I am using smarty within CMSMS and have something called a User Defined Tag running within my page. This contains the following code:

$db = cmsms()->GetDb(); 
$menu = $smarty->get_template_vars('page'); 
$user_id = $smarty->get_template_vars('userid'); 
if (!isset($user_id)) { 
  $user_id = -1; 
} 

// Getting menu items from DB 
$query = 'SELECT * FROM '. cms_db_prefix() .'module_tools_options 
 WHERE active = 1 AND user_id = ? AND menu = ? 
 ORDER BY sort'; 
$dbresult = $db->Execute($query, array($user_id, $menu)); 

while ($dbresult && $row = $dbresult->FetchRow()) { 
$smarty->_compile_source('preprocess template', $row['title'], $_compiled); 
@ob_start(); 
$smarty->_eval('?>' . $_compiled); 
$result = @ob_get_contents(); 
@ob_end_clean(); 
   echo '<li id="menu_' . $row['option_id'] . '">' . $result . "</li>\n"; 
}

I have upgraded the CMSMS installation so it now runs smarty 3 and this has broken my page. I get the following error:

/lib/smarty/sysplugins/smarty_internal_templatebase.php: Call of unknown method '_compile_source'.

I guess the Compile Source method has been depreciated in Smarty 3. Can anyone point me in the right direction of its replacement or a method to get this working again?

Many Thanks

air4x
  • 5,618
  • 1
  • 23
  • 36
user1098178
  • 697
  • 3
  • 9
  • 25

1 Answers1

1

Replace:

$smarty->_compile_source('preprocess template', $row['title'], $_compiled); 
@ob_start(); 
$smarty->_eval('?>' . $_compiled); 
$result = @ob_get_contents(); 
@ob_end_clean(); 

With:

$result = $smarty->fetch('string:'.$row['title']);