Implemented Add a method to fetch noticeTokens or an eventlistener

  • Thread starter Thread starter ragtek
  • Start date Start date
R

ragtek

Guest
It would be much easier to include own vars in the noticeTokens if we would have an event listener with an reference to the noticeTokens or if a method would return the array.

that's the part i mean:
XenForo_ViewRenderer_HtmlPublic
PHP:
$noticeTokens = array(
                    '{name}' => $user['username'] !== '' ? $user['username'] : new XenForo_Phrase('guest'),
                    '{user_id}' => $user['user_id'],
                );

                foreach (XenForo_Application::get('notices') AS $noticeId => $notice)
                {
                    if (!in_array($noticeId, $dismissedNotices)
                        && XenForo_Helper_Criteria::userMatchesCriteria($notice['user_criteria'], true, $user)
                        && XenForo_Helper_Criteria::pageMatchesCriteria($notice['page_criteria'], true, $template->getParams(), $containerData))
                    {
                        $notices[$noticeId] = array(
                            'title' => $notice['title'],
                            'message' => str_replace(array_keys($noticeTokens), $noticeTokens, $notice['message']),
                            'wrap' => $notice['wrap'],
                            'dismissible' => ($notice['dismissible'] && XenForo_Visitor::getUserId())
                        );
                    }
                }
 
Upvote 0
This suggestion has been implemented. Votes are no longer accepted.
There's a listener for this in 1.2, which also lets you modify the notices that will be prepared/displayed as well.
 
Top Bottom