Krel Member Dec 6, 2017 #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.
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.
thedude Well-known member Dec 6, 2017 #2 https://xenforo.com/community/threads/php-callback-from-template.133136/
Krel Member Dec 6, 2017 #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).
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).
Krel Member Dec 7, 2017 #5 Could you please google for me some manuals? I really can't understand what to do and what to change.
Could you please google for me some manuals? I really can't understand what to do and what to change.
Krel Member Dec 13, 2017 #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.
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.
ASap Active member Jan 3, 2019 #7 Krel said: Ok. That's my solution: Create dir at /src/addons/Quotes/ 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. Click to expand... I followed exactly like yours, but still getting Error is: Callback Quotes_Index::getHtml is invalid (error_invalid_class). error message, any clue?
Krel said: Ok. That's my solution: Create dir at /src/addons/Quotes/ 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. Click to expand... I followed exactly like yours, but still getting Error is: Callback Quotes_Index::getHtml is invalid (error_invalid_class). error message, any clue?
Arty Well-known member Jan 3, 2019 #8 Probably there is a error in your php code. You need to post contents of your file.
ASap Active member Jan 3, 2019 #9 Here's my src/addons/PageServed/Index.php (capital i) Code: <?php namespace PageServed; class PageServed_Index { Test html } www@svr:/src/addons/PageServed$ And this is what I use on my template: Code: <xf:callback class="\PageServed\Index" method="getHtml"></xf:callback>
Here's my src/addons/PageServed/Index.php (capital i) Code: <?php namespace PageServed; class PageServed_Index { Test html } www@svr:/src/addons/PageServed$ And this is what I use on my template: Code: <xf:callback class="\PageServed\Index" method="getHtml"></xf:callback>
Arty Well-known member Jan 3, 2019 #10 That's not valid php code. You need to add function inside it: Code: <?php namespace PageServed; class Index { public static function getHtml() { return 'Test html'; } } Also class name is wrong. It should match file name.
That's not valid php code. You need to add function inside it: Code: <?php namespace PageServed; class Index { public static function getHtml() { return 'Test html'; } } Also class name is wrong. It should match file name.