2012-08-06 88 views

回答

1

要檢索組件項目的ID,你需要做幾件事情:

使用創建鏈接到項目它的ID例如

$mylink = 'index.php?option=com_yourcomponent&view=myitemview&id=99' 

你應該再通過該鏈接通過JRoute櫃面用戶已啓用SEF:

$myRoutedLink = JRoute::_($myLink); 

這可確保當你建立你的項目頁面時,試圖訪問該ID是可用的。對於Joomla! 2.5您應該使用JInput來檢索變量,因爲JRequest已被折舊並從J1.7開始被替換。

第一步是獲得Joomla!實例,然後在檢索變量之前輸入對象,例如

// Get Joomla! instance 
$jAp = JFactory::getApplication(); 
$jInput = $jAp->input; 

現在,我們可以得到你的變量:

// Get variables 
$passedID = $jInput->get('id',0) // Where the 0 is the default if 'ID' doesn't exist. 
$passedInt = $jInput->getInt('myInt',0) // You can also get JInput to give the right type back 
0

我知道關於Joomla 1.5.xx

,我已經習慣了得到的itemid從網址爲:

$itemid = JRequest::getVar('itemid'); 

希望這將有助於你還。按照鏈接以獲得更多信息JRequest

+0

感謝所有,$ ID = JRequest :: getInt( '身份證');正在Joomla 2.5工作 – Abhinav 2012-08-06 13:09:34