Allow parsing of BB Code in Poll Responses

Chris D

XenForo developer
Staff member
With an add-on it is actually quite simple to parse poll options with BB Code.

First you extend XenForo_ViewPublic_Thread_View:

PHP:
	public function renderHtml()
	{
		$parent = parent::renderHtml();
		
		if (!empty($this->_params['poll']))
		{
			$bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this)));
			
			foreach ($this->_params['poll']['responses'] AS &$response)
			{
				$response['response'] = new XenForo_BbCode_TextWrapper($response['response'], $bbCodeParser);
			}			
		}
		
		return $parent;		
	}

And then similarly extend XenForo_ViewPublic_Thread_PollResults

After making a small template edit in poll_block_result and poll_block_vote (changing {$response.response} to {xen:raw $response.response}) the end result is as follows:

AyB2FGF.png


I would like to suggest this be considered for the core. As well as allowing us to add more context to polls and poll responses, it is also a feature that is missed when moving from other forum software.

Also worth considering is the VARCHAR length of the xf_poll_response.response field. The length is 100 and although in the context of plain text that is a reasonable length, with BB Code this should probably get larger (preferably to match the same limits provided by PHPBB and vBulletin to aid in imports).
 
Upvote 14
@Chris Deeming
I'm not able to find "PollResults"
Did this change in the last versions of XenForo?
And - is it possible to create an add-on for this needful feature?

Thanks for your support
 
I would like to suggest this be considered for the core. As well as allowing us to add more context to polls and poll responses, it is also a feature that is missed when moving from other forum software.
Hello,
I wonder that do you suggest this after being member of xenforo developer team ? I have moved my forum from Vbulletin and many of my polls have BBCODE. I am looking for solution for this.

Or @Chris D would you please tell us how to make these change detailed ?
 
Back
Top Bottom