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

Implemented Add a method to fetch noticeTokens or an eventlistener

R

ragtek

Guest
#1
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())
                        );
                    }
                }
 

Mike

XenForo developer
Staff member
#4
There's a listener for this in 1.2, which also lets you modify the notices that will be prepared/displayed as well.