Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
检索Joomla 2.5组件项id_Joomla - Fatal编程技术网

检索Joomla 2.5组件项id

检索Joomla 2.5组件项id,joomla,Joomla,我正在开发一个组件,我希望检索项目id并使用该id,以便每次页面加载时,该项目id将用于其他事情。 谢谢我知道joomla 1.5.xx 我从url获取的itemid是: $itemid = JRequest::getVar('itemid'); 希望这也能对你有所帮助。按照链接获取更多信息要检索组件项目的ID,您需要执行以下几项操作: 使用项目的ID创建指向该项目的链接,例如 $mylink = 'index.php?option=com_yourcomponent&view=myi

我正在开发一个组件,我希望检索项目id并使用该id,以便每次页面加载时,该项目id将用于其他事情。
谢谢

我知道joomla 1.5.xx

我从url获取的itemid是:

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

希望这也能对你有所帮助。按照链接获取更多信息

要检索组件项目的ID,您需要执行以下几项操作:

使用项目的ID创建指向该项目的链接,例如

$mylink = 'index.php?option=com_yourcomponent&view=myitemview&id=99'
如果用户已启用SEF,则应通过
JRoute
传递该链接:

$myRoutedLink = JRoute::_($myLink);
这样可以确保在构建项目页面时尝试访问ID时,该ID可用。为了乔姆拉!2.5应使用检索自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

谢谢大家,$id=JRequest::getInt('id');在Joomla 2.5工作