Combine Two Lines of Code ....


Well-known member

I have two lines of code which are leading to a posting behavior that is not as I desire.

    $body = '';
        if($post_contains == 'full')
            $body = $XF->visitor->get('username') . ' submitted a new blog post';
            $body .= '[quote]' . XenForo_Helper_String::autoLinkBbCode(XenForo_Html_Renderer_BbCode::renderFromHtml(nl2br($content))) . "[/quote]";
            /* Add preg_replace */
            $body = preg_replace('#\[nlposts .*\]#', '', $body);
            /* Add Trim to 500 Words */
            $body = XenForo_Helper_String::wholeWordTrim($body, 500);
        $body .= "[URL='" . get_permalink($post->ID) . "']Continue reading the Original Blog Post[/URL]";

The problem is that the Continue reading the Original Blog ends up inside the quote tags.

I keep looking at this code and trying to figure out how to make sure that the link is outside the quote. The resource manager uses a template to achieve the above but I'm not sure how to add templates and get them called properly here.

Does anyone have any suggestions? If you think a template is the best way to accomplish this then is there a write up I've missed which might help?


Well-known member
you don't want to start the quote and then trim it;)
trim the content, put it inside of the quote tags and then add the "continue reading" link


Well-known member
I understand but I believe this is why the two lines need to be combined:

$body .= '' . XenForo_Helper_String::autoLinkBbCode(XenForo_Html_Renderer_BbCode::renderFromHtml(nl2br($content))) . '';


$body = XenForo_Helper_String::wholeWordTrim($body, 500);

This is because if I simply add the line between the Continue .... :

$body = '[quote]' . $body . '[/quote]' ;

Then the username and title end up inside the quotes :(

So, how do I combine two XenForo_Helper_String statements?

I hope that makes sense what I'm asking.


Well-known member

I got it to work. This is how I combined them

$body .= '[quote]' . XenForo_Helper_String::wholeWordTrim(XenForo_Helper_String::autoLinkBbCode(XenForo_Html_Renderer_BbCode::renderFromHtml(nl2br($content))), 500) . '[/quote]';

It seems to be working. As always - thank you for your help!

Let me know if you think there is a better way.