2012-04-15 121 views
0

我有控制器本身正確加載但是我不認爲我有我的控制器根據wiredesignz moduler擴展codeigniter框架插件的文檔正確寫入。我說我可能沒有正確書寫它的原因是因爲我收到了很多錯誤。控制器接收錯誤

錯誤:

A PHP Error was encountered 

Severity: Notice 

Message: Undefined property: CI::$data 

Filename: MX/Controller.php 

Line Number: 58 
A PHP Error was encountered 

Severity: Notice 

Message: Indirect modification of overloaded property Quotes::$data has no effect 

Filename: controllers/quotes.php 

Line Number: 71 

https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home

這裏是我的控制器:

<?php 

if (!defined('BASEPATH')) exit('No direct script access allowed'); 

class Quotes extends MX_Controller 
{ 

public function __construct() 
{ 
    parent::__construct(); 
    $this->load->library('kowauth'); 

} 

public function index() 
{ 
    //Config Defaults Start 
    $msgBoxMsgs = array(); //msgType = dl, info, warn, note, msg 
    $cssPageAddons = ''; //If you have extra CSS for this view append it here 
    $jsPageAddons = ''; //If you have extra JS for this view append it here 
    $metaAddons = ''; //Sometimes there is a need for additional Meta Data such in the case of Facebook addon's 
    $siteTitle = ''; //alter only if you need something other than the default for this view. 
    //Config Defaults Start 


    //examples of how to use the message box system (css not included). 
    //$msgBoxMsgs[] = array('msgType' => 'dl', 'theMsg' => 'This is a Blank Message Box...'); 

    /**********************************************************Your Coding Logic Here, Start*/ 

    // Checks to see if a session is active for user and shows corresponding view page 
    if ($this->kowauth->isLoggedIn()) 
    { 
     $bodyContent = "testing"; //which view file 
    } 
    else 
    { 
     redirect('login', 'refresh'); 
    } 
    $bodyType = "full"; //type of template 

    /***********************************************************Your Coding Logic Here, End*/ 

    //Double checks if any default variables have been changed, Start. 
    //If msgBoxMsgs array has anything in it, if so displays it in view, else does nothing. 
    if (count($msgBoxMsgs) !== 0) 
    { 
     $msgBoxes = $this->msgboxes->buildMsgBoxesOutput(array('display' => 'show', 
      'msgs' => $msgBoxMsgs)); 
    } 
    else 
    { 
     $msgBoxes = array('display' => 'none'); 
    } 

    if ($siteTitle == '') 
    { 
     $siteTitle = $this->metatags->SiteTitle(); //reads 
    } 

    //Double checks if any default variables have been changed, End. 

    $this->data['msgBoxes'] = $msgBoxes; 
    $this->data['cssPageAddons'] = $cssPageAddons; //if there is any additional CSS to add from above Variable this will send it to the view. 
    $this->data['jsPageAddons'] = $jsPageAddons; //if there is any addictional JS to add from the above variable this will send it to the view. 
    $this->data['metaAddons'] = $metaAddons; //if there is any addictional meta data to add from the above variable this will send it to the view. 
    $this->data['pageMetaTags'] = $this->metatags->MetaTags(); //defaults can be changed via models/metatags.php 
    $this->data['siteTitle'] = $siteTitle; //defaults can be changed via models/metatags.php 
    $this->data['bodyType'] = $bodyType; 
    $this->data['bodyContent'] = $bodyContent; 
    $this->data['userData'] = $this->users->getUserByUserID($this->session->userdata('userID')); 
    $roster = $this->kowauth->getRosterList($this->data['userData']->usersRolesID); 
    $userRoster = array(); 
    foreach ($roster AS $member) 
    { 
     $userRoster[$member->id] = $member->rosterName; 
    } 
    $this->data['userRoster'] = $userRoster; 
    $this->data['personalMessages'] = array($this->pmmodel-> 
     getInboxUnreadMessagesCount($this->session->userdata('userID')), $this->pmmodel-> 
     getInboxMessagesCount($this->session->userdata('userID')), $this->pmmodel-> 
     getLast5Messages($this->session->userdata('userID'))); 
    $this->load->view('cpanel/index', $this->data); 
} 
} 

/* End of file quotes.php */ 
/* Location: ./application/modules/bios/controllers/quotes.php */ 

回答

3

我不熟悉的模塊化擴展,但它看起來好像錯誤是你正在嘗試爲$ this->數據賦值而未創建$ this-> data

嘗試添加這一點,看看會發生什麼

class Quotes extends MX_Controller 
{ 
    public $data; 
+0

這是奇怪,因爲所有這些代碼是駐留在應用/控制器的文件夾我的正常控制器的通用模板,我不接受這樣的錯誤在任何那些。 – 2012-04-15 19:49:06

+0

這不是我親自使用的,你也可以嘗試創建一個數組$ data,將所有這些值設置爲該數組,然後傳遞它。所以$ this-> data ['msgBoxes'] = $ msgBoxes;會是$ data ['msgBoxes'] = $ msgBoxes,$ this-> load-> view('cpanel/index',$ this-> data);會變成$ this-> load-> view('cpanel/index',$ data); – Dale 2012-04-15 19:51:31

+1

答案實際上是我應該在控制器的擴展中使用CI而不是MX。我想我不太瞭解一些插件。 – 2012-04-15 20:13:37