Page 1 of 1

Execute plugin from UDT

Posted: Tue Apr 23, 2013 11:34 am
by tom3232
Dear community,

I have got a - for me challenging - question. The following code was working properly in CMSMS 1.10, but now in version 1.11 and Smarty 3, I'm always getting an error:

Code: Select all

  $gCms = cmsms();
  $smarty = &$gCms->GetSmarty();
  $smarty_data = "{cropnewsimage target_size_x='114' target_size_y='88' feld_id='1' output='thumb_register_'}";
  $smarty->_compile_source('temporary template', $smarty_data, $_compiled );
  @ob_start();
  $smarty->_eval('?>' . $_compiled);
  $_contents = @ob_get_contents();
  @ob_end_clean();
Calling the UDT, the following error occurs:

Code: Select all

Call of unknown method '_compile_source'.
The purpose of the code is to execute a plugin from a user defined tag. I think the method "_compile_source" is deprecated in Smarty 3. Can anyone help me?

Re: Execute plugin from UDT

Posted: Tue Apr 23, 2013 12:13 pm
by Jos
I think this piece of documentation can help you: http://www.smarty.net/docs/en/resources.string.tpl

Re: Execute plugin from UDT

Posted: Tue Apr 23, 2013 12:28 pm
by Jo Morg
Also I believe that you can't redefine $smarty inside of the UDT as of 1.11.x CMSMS versions.
To check that just try this:

Code: Select all

  
  #$gCms = cmsms(); #<-- comment out
  #$smarty = &$gCms->GetSmarty(); #<-- comment out
  $smarty_data = "{cropnewsimage target_size_x='114' target_size_y='88' feld_id='1' output='thumb_register_'}";
  $smarty->_compile_source('temporary template', $smarty_data, $_compiled );
  @ob_start();
  $smarty->_eval('?>' . $_compiled);
  $_contents = @ob_get_contents();
  @ob_end_clean();
  $smarty_data = "{cropnewsimage target_size_x='114' target_size_y='88' feld_id='1' output='thumb_register_'}";
  $smarty->_compile_source('temporary template', $smarty_data, $_compiled );
  @ob_start();
  $smarty->_eval('?>' . $_compiled);
  $_contents = @ob_get_contents();
  @ob_end_clean();
And see if it works.
HTH

Re: Execute plugin from UDT

Posted: Thu Apr 25, 2013 8:17 am
by Rolf