2012-08-06 87 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