2013-04-11 77 views
0

我正在創建一個joomla2.5模塊。 我想從模塊中檢索數據傳遞參數,但是得到關於標題的錯誤。下面是我的代碼: helper.php致命錯誤:調用joomla2.5中的一個非對象的成員函數get()

class modFeedGrabber 
{ 
    function feedurl(){ 
     $url = $params->get('feedUrl'); 
     return $url; 
    } 
    function maxCount(){ 
     $maxcount = $params->get('maxCount'); 
     return $maxcount; 
    } 
    function showDesc(){ 
     return $params->get('showDesc'); 
    } 
    function showPubDate(){ 
     return $params->get('showPubDate'); 
    } 
    function targetLink(){ 
     return $params->get('titleLinkTarget'); 
    } 
    function descChar(){ 
     return $params->get('descCharacterLimit'); 
    } 
    function fx(){ 
     return $params->get('fx'); 
    } 
    function delay(){ 
     return $params->get('delay'); 
    } 
    function timeout(){ 
     return $params->get('timeout'); 
    } 
    function module_sfx(){ 
     return $params->get('moduleclass_sfx'); 
    } 
} 

mod_feedGrabber.php

defined('_JEXEC') or die('Restricted access'); 

$sitebase = JPATH_BASE; 
$doc =& JFactory::getDocument(); 

// Include the syndicate functions only once 
require_once(dirname(__FILE__).DS.'/helper.php'); 
$feed = new modFeedGrabber(); 
$url = $feed->feedurl($url); 
$maxcount = $feed->maxcount($maxcount); 
require(JModuleHelper::getLayoutPath('mod_feedGrabber')); 

我的新quetion是我怎樣才能得到的數據從模塊通過了嗎?

+0

無處你在你的代碼定義'$ url',讓你有效地考取給你的方法一個'null'值。 – 2013-04-11 19:30:29

+0

$ url是在方法函數feedurl()中定義和賦值的() – jking 2013-04-11 19:32:06

+0

@ user1230116 - 該方法需要一個參數,並且正在傳入「$ url」,這是underfined。然後它會使用這個未定義的參數的get方法,這就是爲什麼你會得到一個錯誤。 – andrewsi 2013-04-11 19:33:56

回答

0

爲了說明我上面的評論:

$url = $feed->feedurl($url); 
         ^^^^---- $url is not defined at this point 

如果feedurl()返回$ url值無關緊要。在你嘗試傳入方法的時候,你沒有定義這個方法CALL feedurl(),$url。 SO feedurl(),你在做

$url = $params->get(...); 
     ^^^^^^^---the $url you passed in to the method, which is null/undefined 

然後內,當然,還有其他的問題:

$url = $params->get(feedUrl); 
         ^^^^^^^--- undefined constant 
+0

如何從模塊接口創建數據傳遞來自xml – jking 2013-04-11 19:47:48

相關問題