• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 2.0 xf2 callback. insert php in template.

#1
Hello.
This code worked with xf1.x.
Code:
<xen:callback class="Quotes_Index" method="getHtml"></xen:callback>
After upgrade to 2.0 this code doesn't work.
Please tell me how change this code for xenforo 2? I'd like to insert php in my template xf2.
 
#3
Not works.
I put in library/Quotes/Index.php
Code:
<?php
class Quotes_Index
{
public static function getHtml()
{
//include '\library\Example\Srv_Status.php';
include '/var/www/html/quotes.php';
return $output;
}
}
?>
Then I tryed insert in template
Code:
<xf:callback class="Quotes_Index" method="getHtml"></xf:callback>
But it does't work. What i do wrong? :(

Error is: Callback Quotes_Index::getHtml is invalid (error_invalid_class).
 
#6
Ok. That's my solution:

1. Create dir at /src/addons/Quotes/
2. put there file touch /src/addons/Quotes/Quotes_Index.php
Code:
<?php
namespace Quotes;
class Quotes_Index
{
your code here
}
3. In template insert
Code:
<xf:callback class="\Quotes\Quotes_Index" method="getHtml"></xf:callback>
It works well.