简体   繁体   English

如何将当前用户ID添加到joomla中的菜单链接

[英]how to add current user id to menu link in joomla

I want to pass the user id as filter with menu link to select items from list of database object that belong to that user. 我想通过菜单链接传递用户ID作为筛选器,以从属于该用户的数据库对象列表中选择项目。 How to add current user id to menu link. 如何将当前用户ID添加到菜单链接。 The xml file parmaters are static I think. 我认为xml文件的参数是静态的。 They doesnt work. 他们不工作。

You don't need to add the User ID to the menu link (and security wise it's probably a very bad idea). 您无需将用户ID添加到菜单链接(从安全角度考虑,这可能是一个非常糟糕的主意)。 You can retrieve the User ID of the current user anywhere in Joomla!. 您可以在Joomla!中的任何位置检索当前用户的用户ID。

eg ( you haven't specified your Joomla! version but for 2.5 you can get it this way ) 例如( 您尚未指定您的Joomla!版本,但对于2.5,您可以通过这种方式获得它

$user = JFactory::getUser();
$userId = $user->get('id');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM