$formatter = XenForo_BbCode_Formatter_Base::create('Base');
$parser = new XenForo_BbCode_Parser($formatter);
foreach($tasks as $task)
{
$tasks[$task['task_id']]['title'] = $parser->render($task['title']);
}
$template->setParam('tasks', $tasks);
$template->setParam('completed', $completed);
Yup, that's what I'm doingSpontaneously looking at it makes me think of an error in the template. You should be using {xen:raw $yourcontentvariable} there to have it fully rendered.
There's no clean and easy way to do this, you need to get the view before calling the "notices_prepare" hook. This addon does this. Look at this file on Github.How do you go about rendering BBCode in notices? They can be global, so there's not exactly a view for it that you can render in. If I add the parser into the place where I hook into notices_prepare I just get 'p' dumped to the top of the page.
Thanks!There's no clean and easy way to do this, you need to get the view before calling the "notices_prepare" hook. This addon does this. Look at this file on Github.
public static function add_notice(array &$noticeList, array &$noticeTokens, XenForo_Template_Abstract $template, array $containerData)
{
$visitor = XenForo_Visitor::getInstance();
$options = XenForo_Application::getOptions();
$bbCodeMode = false;
/* @var $progressModel Apantic_UserProfileProgress_Model_UserProfileProgress */
$progressModel = XenForo_Model::create('Apantic_UserProfileProgress_Model_UserProfileProgress');
$tasks = $progressModel->getTasks(array('active' => 1));
if($options->auppEnableViewHook)
{
$bbCodeParser = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('Base', array(
'view' => self::$_view
)));
$bbCodeMode = true;
}
if(!empty($visitor['user_id'])
&& $visitor['aupp_percent_completed'] < 100
/* && $visitor->hasPermission('', '')*/
)
{
$completed = $progressModel->getTasksCompletedByUser($visitor);
if(empty($tasks))
{
return;
}
if($bbCodeMode)
{
foreach($tasks as $task)
{
$tasks[$task['task_id']]['title'] = $bbCodeParser->render($task['title']);
}
}
$template->setParam('tasks', $tasks);
$template->setParam('completed', $completed);
$noticeList['auppPendingTasks'] = array(
'title' => new XenForo_Phrase('aupp_notice_title'),
'message' => $template->create('aupp_notice_tasks', $template->getParams()),
'wrap' => true,
'dismissible' => false,
'delay_duration' => '',
'display_duration' => '',
'auto_dismiss' => false,
'display_image' => '',
'display_style' => 'primary',
'css_class' => '',
'visibility' => '',
'notice_type' => ($options->auppNoticeLocation == 'floating' ? 'floating' : 'block')
);
$tokens = array(
'{progress}' => $visitor['aupp_percent_completed'],
);
$noticeTokens = array_merge($noticeTokens, $tokens);
}
}
public static function controllerPreView(XenForo_FrontController $fc,
XenForo_ControllerResponse_Abstract &$controllerResponse,
XenForo_ViewRenderer_Abstract &$viewRenderer,
array &$containerParams
)
{
if(!($viewRenderer instanceof XenForo_ViewRenderer_Json)
&& XenForo_Application::get('options')->get('auppEnableViewHook')
)
{
$response = $fc->getResponse();
self::$_view = new XenForo_ViewPublic_Base($viewRenderer, $response, $containerParams);
}
}
Sorry no time to check your code, but be sure to take a look at this helper; it's working with the Github file I gave you above.@cclaerhout I still see 'p' dumped to the top of the page, however it does work.
Using the Bb Codes parser after a content has been parsed in hml requires to use workarounds (see my previous message).I do not see anything in the code that could cause that p to appear
Definitely isn't working, triple checked it all and made sure to use the helpers, too.Using the Bb Codes parser after a content has been parsed in hml requires to use workarounds (see my previous message).
If you use my addon, can you reproduce the problem?Definitely isn't working, triple checked it all and made sure to use the helpers, too.
We use essential cookies to make this site work, and optional cookies to enhance your experience.