Trim and BBCode

Status
Not open for further replies.

Steven Moore

OMG Member
Joined
Oct 22, 2010
Messages
1,084
In my portal system I need to trim latest news article to a certain amount of characters before the read more link appears, but I can't figure that out as well as I need to convert bbcode for displaying on my portal.

Here is my latest news model:
PHP:
class xPortal_Model_News extends XenForo_Model
{
    public function getNews()
    {
        $nOption = XenForo_Application::get('options')->xportal_news;

        $nThread = $this->limitQueryResults('
            SELECT
                thread.title, thread.first_post_id, thread.username, post.*, user.*
            FROM xf_thread AS thread
            LEFT JOIN xf_post AS post ON (post.post_id = thread.first_post_id)
            LEFT JOIN xf_user AS user ON (user.username = thread.username)
            WHERE thread.node_id = ?
        ', $nOption);

        return $this->_getDb()->fetchRow($nThread, $nOption);
    }
}

Same thing for my latest posts. Here is my latest posts model:
PHP:
class xPortal_Model_LatestPosts extends XenForo_Model
{
    public function getLatestPosts()
    {
        $lPosts = $this->limitQueryResults('
            SELECT post.*, thread.*
            FROM xf_post AS post
            LEFT JOIN xf_thread AS thread ON (thread.thread_id = post.thread_id)
            WHERE message_state = "visible"
            ORDER BY post.post_date
        ', 5);

return $this->_getDb()->fetchAll($lPosts);
    }
}

Thanks in advance
 

Mikey

:mikey:
Staff member
Joined
Jan 26, 2008
Messages
17,835
Would you not do something with substr and strlen ? If the string is so long (detect via strlen (?) ) then shorten it or add ... to the end (via substr (?) )
 

Steven Moore

OMG Member
Joined
Oct 22, 2010
Messages
1,084
I managed to use {xen:helper snippet, $post.message, 100} for it. Now the BBCode stuff is all I have left to figure out.
 
Status
Not open for further replies.
Top