Formatting Data Extracted From Database

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. :)

Roh.php
Code:
<?php

class ExternalPages_ControllerPublic_Roh extends XenForo_ControllerPublic_Abstract
{
    public function actionIndex()
    {
        $visitor = XenForo_Visitor::getInstance();
        $sessionModel = $this->getModelFromCache('XenForo_Model_Session');

        $onlineUsers = $sessionModel->getSessionActivityQuickList(
            $visitor->toArray(),
            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);
    }
}

Template:
Code:
<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:navigation>
    <xen:breadcrumb href="{xen:link full:en/roh/}">Roll Of Honour</xen:breadcrumb>
</xen:navigation>

About The Site:<br />
{$aboutthesite}
<hr />
Images: {$stats_numimages}<br />
Views: {$stats_numviews}

<xen:sidebar>
    <xen:include template="sidebar_online_users" />
    <xen:include template="forum_stats" />
    <xen:include template="sidebar_share_page" />
</xen:sidebar>
 
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.
 
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.
Thanks, I found the below code, but i don't know how to add the code to the above to get it working? :confused:
Code:
<?php

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');
        }
    }
}
 
Top Bottom