XF 2.0 how to pass a $variable or $object to php file from template using xf:callback params?

Earl

Well-known member
I have this HTML type widget in the search_results template which has access to the $search object of the search_results template.
(template passes $search to the widget via a context variable context-search, I'm using template modification to add the widget position to the search_results template)


So, basically I have a template named _widget_my_recent_searches and it has access to $search object via $context.search

1526396250681.webp

I can only get the value of $context.search.search_type if I put it between <xf:callback> tags{here} </callback>, but I'm already using it to pass the value of $context.search.search_query
I want to pass the value of $context.search.search_type using params="{here}"

But this is not working, when I debug the code, This string value: "##0" coming as $param o_O:unsure:

HTML:
<xf:callback class="Earl\\AddOn\\Callback" method="getHtml" params="['test','{{$context.search.search_type}}']">{$context.search.search_query}</xf:callback>

1526397430700.webp



Can you spot the problem? Is this possible? What am I doing wrong?
 
Last edited:
If you have test2 it works ok? I thought a single {} was for variables and {{}} for functions?
Assuming you are referring to test in params,
yes simple strings works fine, but if I put a variable, it gives "##0" as a string, and If I put another variable, it gives "##1", and another, "##2,.. so on.

func_get_args() also returns same strange "##0" strings :rolleyes:
 
have you tried:

<xf:callback class="Earl\\AddOn\\Callback" method="getHtml" params="['test','{$context.search.search_type}']">{$context.search.search_query}</xf:callback>
?
 
have you tried:

<xf:callback class="Earl\\AddOn\\Callback" method="getHtml" params="['test','{$context.search.search_type}']">{$context.search.search_query}</xf:callback>
?
Yes,

HTML:
<xf:callback class="Earl\\AddOn\\Callback" method="getHtml" params="['test','{{ $context.search.search_type }}']">{$context.search.search_query}</xf:callback>

and
HTML:
<xf:callback class="Earl\\AddOn\\Callback" method="getHtml" params="['test','{$context.search.search_type}']">{$context.search.search_query}</xf:callback>

gives the same result as in screenshot
 
Top Bottom