Handling for Custom BBcodes when Quoted?

Jaxel

Well-known member
I have a custom bbcode with XenCarta...
Code:
[wiki=full]movelist-input-guide[/wiki]

This code will actually embed a full wiki article into a post... example:
http://8wayrun.com/threads/ok-im-here-wheres-the-frame-data-i-should-be-looking-at.7561/#post-249272

However, a problem arises when someone QUOTES this post. Everything shows up fine, but it takes up a lot of room, and its really poor form to have that much information in a quote. Is there a way I can program it so that if the code is found within a quote, it will render differently?
 
If you're talking about "reply" link, it takes out [quote] via JS I believe. As quotes are pre-removed. But doing
fine ( [quote][quote]works[/quote]just[/quote]). If you want to remove [wiki] not using JS, I'd suggest you override the XenForo_BbCode_Formatter_Base::renderTagQuote() function to physically remove them or write it as [plain][wiki][/plain].[/quote]
 
Actually, the process is thus:

Hitting reply makes a call to XenForo.QuickReplyTrigger() in discussion.js, which makes an ajax call to the href within the link (threads/handling-for-custom-bbcodes-when-quoted.17442/reply?quote=227829 for your posted).

Within XenForo_ControllerPublic_Thread::actionReply(), you find this:
PHP:
$defaultMessage = $postModel->getQuoteTextForPost($quotePost);
This function calls
[/php]XenForo_Helper_String::stripQuotes($post['message'], $maxQuoteDepth);[/php]

So, my suggestion would be to create an event listener for load_class_model, extend the post model and create the following new getQuoteTextForPost($quotePost):
PHP:
class KingK_Model_Post extends XFPC_KingK_Model_Post
{
public function getQuoteTextForPost(array $post, $maxQuoteDepth = 0)
{
$message = parent::getQuoteTextForPost($post, $maxQuoteDepth);
$message = $this->_stripWiki($post);
return $message;
}

protected function _stripWiki($post)
{
$post['message'] = str_replace('[wiki=full]', '[url=index.php?wiki/', $post['message']);
$post['message'] = str_replace('[/wiki]', ']', $post['message']);
return $post['message'];
}
}

Although, I'm sture my _stripWiki() could be improved.
 
I'm having trouble with this...
Code:
<?php

class EWRcarta_Model_Post extends XFCP_EWRcarta_Model_Post
{
public function getQuoteTextForPost(array $post, $maxQuoteDepth = 0)
{
$response = parent::getQuoteTextForPost($post, $maxQuoteDepth);
$response = str_ireplace('[wiki=full]', '[wiki]', $response);
return $response;
}
}
Doesnt seem to work at all...
 
Top Bottom