Xen:callback tag

Yes, you can, just pass the parameter using the "params":

Code:
<xen:callback class="Example_Banner_Index" method="printSomethingBold" params="Hello World!"></xen:callback>

Then in the code, you can get the parameter (there is another ways):

Code:
<?php

class Example_Banner_Index
{
    public static function printSomethingBold()
    {
        $phrase = func_get_arg(1);
        return '<b>' . $phrase . '</b>';
    }
}

Also, you can pass an array using this:

Code:
params="{xen:array 'thread={$thread}'}"
I used "params="{$xenOptions.dadparvar_newsticker_char_limit}" in callback and "$charlimit = func_get_arg(1);" in my php file.
Then used "$charlimit" where i Needed. And worked as it must. Thanks.

But how to pass more params to php file and get and use it php file in different places?
 
I used this to pass more params:
Code:
params="{xen:array 'charlimit={$xenOptions.dadparvar_newsticker_char_limit}', 'newscount={$xenOptions.dadparvar_newsticker_count}'}"
and used these in php file:
Code:
    $charlimit = func_get_arg(charlimit);
    $newscount = func_get_arg(newscount);
But not worked.
 
@Dadparvar

I'd spontaneously try
Code:
    $charlimit = func_get_arg(1);
    $newscount = func_get_arg(2);
Not sure why is not working.
can you write full param also please?
Is it right now?
Code:
params="{xen:array '1={$xenOptions.dadparvar_newsticker_char_limit}', '2={$xenOptions.dadparvar_newsticker_count}'}"
and:
Code:
    $charlimit = func_get_arg(1);
    $newscount = func_get_arg(2);
I use it, but just first one is working.
 
Checked it. That's how it works:

HTML:
<xen:callback method="getSomethingDone" class="KL_Test" params="{xen:array '1=X', '2=Y'}"></xen:callback>

PHP:
<?php

class KL_Test {
    public static function getSomethingDone() {
        $arguments = func_get_arg(1);
      
        $x= $arguments[1];
        $y= $arguments[2];
      
        //TODO: Do Stuff
      
        return '';
    }
}
 
It should be noted that it does not work to use a callback as a phrase parameter:
HTML:
{xen:phrase my_phrase, 'my_var=<xen:callback class="MyClass" method="myMethod" />'}
In this case, the callback is never executed and returns an empty string. Instead, you must do the following:
HTML:
<xen:set var="$my_temporary_var"><xen:callback class="MyClass" method="myMethod" /></xen:set>
{xen:phrase my_phrase, 'my_var={xen:raw $my_temporary_var}'}
 
Top Bottom