2012-04-05 88 views
1

我正嘗試構建一個外部webApp來上傳Joomla中的一些產品!憑藉virtmart。
所有預期的工作,但我仍然有問題Jfactory::getApplicationjoomla Jfactory沒有在joomla webapp中實例化自己(joomla 2.5)

我按照這個教程:

http://docs.joomla.org/How_to_create_a_stand-alone_application_using_the_Joomla!_Platform

但是,當我走在__construct方法調用VmModel它稱之爲parent::__construct($config)

$this->_cidName = $cidName; 
// Get the pagination request variables 
$mainframe = JFactory::getApplication() ; 
$limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); 

這就提出了以下錯誤:

vCall to undefined method JException::getUserStateFromRequest()

如果能幫助還有:

vNotice: Trying to get property of non-object in /home/giuseppe/homeProj/ModaNuovo/libraries/joomla/application/application.php on line 201

被提出:

public static function getInstance($client, $config = array(), $prefix = 'J') 
{ 
    if (empty(self::$instances[$client])) 
    { 
     // Load the router object. 
     $info = JApplicationHelper::getClientInfo($client, true); 

     $path = $info->path . '/includes/application.php'; 
     if (file_exists($path)) 
+0

問題是JApplicationWeb沒有擴展JApplication,並且試圖使它擴展那些方法被保護! – giuseppe 2012-04-06 09:09:25

+0

這可能是Joomla3.x更好的方式。 $ app = JFactory :: getApplication('site'); \t //初始化應用程序。 \t $ app-> initialise(); – Anant 2016-10-21 08:50:18

回答

0

解決的辦法是與你的一個共同實例的主要應用程序,並在必要時也登錄方式如下:

$app = JFactory::getApplication('administrator'); 

// create a form token 
$user = JFactory::getUser(42); 
$session = JFactory::getSession(); 
$hash = JApplication::getHash($user->get('id', 0) . $session->getToken(true)); 

如果需要,您還必須執行登錄以驗證此散列。