1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Formatting Data Extracted From Database

Discussion in 'XenForo Development Discussions' started by Craigr, Mar 7, 2012.

  1. Craigr

    Craigr Active Member

    Using this tutorial i have made a page where i query a few things from the database. I have previous entry that was entered using BB Code and shows fine in the database, but when it is displayed on the new page that i have created there are no line breaks, etc. Just wondering how to make it show that the BB Code works. I have attached my PHP file below with the query. The one i am trying to parse is $query_results['intro_text']. Any help would be appreciated. :)

    class ExternalPages_ControllerPublic_Roh extends XenForo_ControllerPublic_Abstract
        public function actionIndex()
            $visitor = XenForo_Visitor::getInstance();
            $sessionModel = $this->getModelFromCache('XenForo_Model_Session');
            $onlineUsers = $sessionModel->getSessionActivityQuickList(
                array('cutOff' => array('>', $sessionModel->getOnlineStatusTimeout())),
                ($visitor['user_id'] ? $visitor->toArray() : null)
            $boardTotals = $this->getModelFromCache('XenForo_Model_DataRegistry')->get('boardTotals');
            if (!$boardTotals)
                $boardTotals = $this->getModelFromCache('XenForo_Model_Counters')->rebuildBoardTotalsCounter();
            $db = XenForo_Application::get('db');
            $query_results = $db->fetchRow("SELECT intro_text,stats_numimages,stats_numviews FROM `bb1_gallery_settings` WHERE settingid = 1");
            $viewParams = array(
                'onlineUsers' => $onlineUsers,
                'boardTotals' => $boardTotals,
                'aboutthesite' => $query_results['intro_text'],
                'stats_numimages' => $query_results['stats_numimages'],
                'stats_numviews' => $query_results['stats_numviews']
            return $this->responseView('ExternalPages_ViewPublic_Advertise', 'ROH_index', $viewParams);
    <xen:h1>Special Forces Roll Of Honour</xen:h1>
    <xen:title>Special Forces Roll Of Honour</xen:title>
    <xen:description>A memorial to Special Forces past,present and future.</xen:description>
        <xen:breadcrumb href="{xen:link full:en/roh/}">Roll Of Honour</xen:breadcrumb>
    About The Site:<br />
    <hr />
    Images: {$stats_numimages}<br />
    Views: {$stats_numviews}
        <xen:include template="sidebar_online_users" />
        <xen:include template="forum_stats" />
        <xen:include template="sidebar_share_page" />
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Normally you would use your view class (ExternalPages_ViewPublic_Advertise) to apply the bbcode parser. See XenForo_ViewPublic_Thread_View as an example. You can see that class passes the posts in a thread to the parser.
    Craigr likes this.
  3. Craigr

    Craigr Active Member

    Thanks, I found the below code, but i don't know how to add the code to the above to get it working? :confused:
    class XenForo_ViewPublic_Thread_View extends XenForo_ViewPublic_Base
        public function renderHtml()
            $bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this)));
            $bbCodeOptions = array(
                'states' => array(
                    'viewAttachments' => $this->_params['canViewAttachments']
            XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages($this->_params['posts'], $bbCodeParser, $bbCodeOptions);
            if (!empty($this->_params['canQuickReply']))
                $this->_params['qrEditor'] = XenForo_ViewPublic_Helper_Editor::getQuickReplyEditor($this, 'message');

Share This Page