Combine Two Lines of Code ....

LPH

Well-known member
Hi

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

PHP:
    $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?
 
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
 
I understand but I believe this is why the two lines need to be combined:

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

and

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

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

PHP:
$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.
 
YES !

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

PHP:
$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.
 
Top Bottom