XF 2.2 MultiQuote Question

Lawrence

Well-known member
I have a template modification applied to the post_macros template. What it does is checks to see if a member who does not have the permission to make a reply to a thread has the permission to use the multi quote, and if so it shows the +Quote button. That works.

However when I select +Quote it does not respond with the: 'message added to multi-quote', but rather opens up the editor and injects the quoted message there. I do not understand why this is happening. The template modification just duplicates the actual multi-quote button:

HTML:
<xf:set var="$quoteLink">{{ link('threads/reply', $thread, {'quote': $post.post_id, 'mq-add': true}) }}</xf:set>
<xf:if is="$xf.options.multiQuote AND $xf.visitor.user_id">
    <a href="{$quoteLink}"
        class="actionBar-action actionBar-action--mq u-jsOnly js-multiQuote"
        title="{{ phrase('toggle_multi_quote_tooltip')|for_attr }}"
        data-message-id="{$post.post_id}"
        data-mq-action="add">{{ phrase('quote') }}</a>
</xf:if>

Note that in the above code I pass an additional parameter to actionReply. All it does is to check if the reply came from the +Quote, and if not returns the parent. If so, then it executes the new action reply (which just removes the canReply permission check and a couple of little things not needed, everything else is the same):

PHP:
class Thread extends XFCP_Thread
{
    public function actionReply(ParameterBag $params)
    {
        if (!$mqAdd = $this->filter('mq-add', 'uint'))
        {
            return parent::actionReply($params);
        }
        $visitor = \XF::visitor();

        $thread = $this->assertViewableThread($params->thread_id, ['Watch|' . $visitor->user_id]);
        if (!$thread->canUseEaeatMultiQuote($error))
        {
            return $this->noPermission($error);
        }

        $defaultMessage = '';
        $forceAttachmentHash = null;

        if ($quote = $this->filter('quote', 'uint'))
        {
            $post = $this->em()->find('XF:Post', $quote, 'User');
            if ($post && $post->thread_id == $thread->thread_id && $post->canView())
            {
                $defaultMessage = $post->getQuoteWrapper(
                    $this->app->stringFormatter()->getBbCodeForQuote($post->message, 'post')
                );
                $forceAttachmentHash = '';
            }
        }

        $viewParams = [
            'thread' => $thread,
            'forum' => $thread->Forum,
            'attachmentData' => $this->getReplyAttachmentData($thread, $forceAttachmentHash),
            'defaultMessage' => $defaultMessage
        ];
        return $this->view('XF:Thread\Reply', 'thread_reply', $viewParams);
    }
}

So, why when I click +Quote the message is not added to multi-quote, but rather sent directly to the editor?

Thank-you, :)
 
Got it figured out, needed to call the button macro in the multi_quote_macro template, :)

Here is my updated template that is inserted if a member can not reply to a thread:

HTML:
<xf:set var="$quoteLink">{{ link('threads/reply', $thread, {'quote': $post.post_id, 'mq-add': true}) }}</xf:set>
<xf:if is="$xf.options.multiQuote AND $xf.visitor.user_id">
    <a href="{$quoteLink}"
        class="actionBar-action actionBar-action--mq u-jsOnly js-multiQuote"
        title="{{ phrase('toggle_multi_quote_tooltip')|for_attr }}"
           data-xf-click="multiQuote"
        data-message-id="{$post.post_id}"
        data-mq-action="add">{{ phrase('quote') }}</a>

    <span style="display: none;">
        <xf:macro template="multi_quote_macros" name="button"
            arg-href="{{ link('threads/multi-quote', $thread) }}"
            arg-messageSelector=".js-post"
            arg-storageKey="multiQuoteThread" />
    </span>
</xf:if>

Now members can multi-quote posts in threads that they can not reply to.

multiquote.png
 
Last edited:
Back
Top Bottom