Hello
I have followed many threads, but I can't seem to make a PHP callback that returns data properly. I keep getting the following error:
Callback:
Template:
I have followed many threads, but I can't seem to make a PHP callback that returns data properly. I keep getting the following error:
An exception occurred: [TypeError] Argument 1 passed to Site\Pages\Providers::getData() must be an instance of XF\Pub\Controller\AbstractController, string given in src/addons/Site/Pages/Providers.php on line 6
What am I doing wrong?Callback:
Code:
<?php
namespace Site\Pages;
class Providers {
public static function getData(\XF\Pub\Controller\AbstractController $controller, \XF\Mvc\Reply\AbstractReply &$reply) {
if ($reply instanceof \XF\Mvc\Reply\View) {
$providers = \XF::db()->fetchAll("
SELECT
t.thread_id,
t.view_count,
t.title,
p.post_id,
p.message,
p.post_date,
u.user_id,
u.username,
u.custom_title,
u.avatar_date,
g.banner_css_class,
g.banner_text
FROM (
SELECT th.thread_id, th.title, th.view_count
FROM xf_thread AS th
INNER JOIN xf_thread_prefix AS px ON th.prefix_id=px.prefix_id
WHERE px.prefix_id=1
) AS t
INNER JOIN xf_post AS p ON t.thread_id=p.thread_id
INNER JOIN xf_user AS u ON p.user_id=u.user_id
INNER JOIN xf_user_group AS g ON u.user_group_id=g.user_group_id
WHERE p.position=0
ORDER BY p.post_date DESC
");
$reply->setParam('providers', $providers);
}
}
}
Template:
Code:
<xf:callback class="Site\Pages\Providers" method="getData"></xf:callback>
<xf:foreach loop="$providers" value="$provider">
Admin={$provider.provider_key}:WhiteList // {$provider.user_id} {$provider.username}<br>
</xf:foreach>