grantus
Active member
My alert code is sending an alert to the appropriate user and it shows up with a "1" in the alert notification, but the alert is not showing anything. And when I go to the Alert page it doesn't show anything either. I'm assuming it's because the alert template is not named properly.
Here is my alert:
I have an Alert.php page under Battles\ILL\Alert with:
I've set up the content types like this:
I see that the alert is inserted properly into the xf_user_alert table, so what should the alert template be named?
Here is my alert:
Code:
$receiver = \XF::finder('XF:User')->where('user_id', 24495)->fetchOne();
if ($receiver) {
$sender = \XF::finder('XF:User')->where('user_id', 1)->fetchOne();
$alertRepo = $this->repository('XF:UserAlert');
$alertRepo->alert(
$receiver,
$sender->user_id,
$sender->username,
'newbattle',
1111,
'battle',
["value1" => 01, "value2" => 02, "status" => "active", 'depends_on_addon_id' => 'Battles/ILL']
);
}
I have an Alert.php page under Battles\ILL\Alert with:
Code:
namespace Battles\ILL\Alert;
use XF\Alert\AbstractHandler;
use XF\Entity\UserAlert;
class NewBattle extends AbstractHandler {
public function canViewAlert(UserAlert $alert, &$error = null): bool {
return true;
}
}
I've set up the content types like this:
Code:
content type: newbattle
field: entity
value: Battles\ILL:NewBattle
addon: Battles
content type: newbattle
field: alert_handler_class
value: Battles\ILL\Alert\NewBattle
addon: Battles
I see that the alert is inserted properly into the xf_user_alert table, so what should the alert template be named?