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

Problem displaying alert.

Discussion in 'XenForo Development Discussions' started by Jake B., Feb 9, 2014.

  1. Jake B.

    Jake B. Well-Known Member

    I'm currently working on an addon, and I'm having a problem getting it to display the alerts after a certain action happens. I have created the appropriate rows in xf_content_type, and xf_content_type_field and pointed it towards my AlertHandler, which is being called. But for some reason it will not display the alert. It shows that I have a new alert, but doesn't display it.

    Here is my alert handler:
    class XenStop_Casino_AlertHandler_Casino extends XenForo_AlertHandler_Abstract
        protected $_postModel = null;
        public function getContentByIds(array $contentIds, $model, $userId, array $viewingUser)
            $betModel = $model->getModelFromCache('XenStop_Casino_Model_Casino');
            return $betModel->getBetsByIds($contentIds);
        protected function _prepareAlertBeforeAction(array $item, $content, array $viewingUser)
                if ($item['extra_data']) {
                    $item['extra'] = unserialize($item['extra_data']);
                    $item['winlose'] = $item['extra']['win_lose'];
                    if($item['winlose'] == 1) {
                        $item['amount'] = intval($item['extra']['bet_amount']) * 2;
                    } else {
                        $item['amount'] = $item['extra']['bet_amount'];
            return $item;
        protected function _getDefaultTemplateTitle($contentType, $action) {
            return 'xenstop_casino_alert';
    It is selecting all of the rows from in the getContentByIds function, but the _prepareAlertBeforeAction function isn't even running.
  2. Syndol

    Syndol Guest

    1). Did you rebuild the content type cache after you inserted them? Can be done via function rebuildContentTypeCache()
    2). In your _prepareAlertBeforeAction() you are unsetting extra_data which function prepareAlert() looks for. Personally I would run you code via the _prepareAction() function (where Action is the action of your alert - such as 'win', 'lose').
  3. Jake B.

    Jake B. Well-Known Member

    1) Yes I did.
    2) That isn't the problem, the '_prepareAlertBeforeAction' isn't even running

    EDIT: I fixed the issue by removing the unset($item['extra_data']);

    Thanks for the assistance @Syndol
    Last edited: Feb 9, 2014

Share This Page