Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.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中获取作者姓名_Joomla_Alias_Author - Fatal编程技术网

在Joomla 2.5中获取作者姓名

在Joomla 2.5中获取作者姓名,joomla,alias,author,Joomla,Alias,Author,如何在Joomla 2.5中获得当前文章的作者姓名 我试着用这个密码,但它给了我号码 $id = JRequest::getInt('id'); $article =& JTable::getInstance('content'); $article->load($id); $article_author = $article->created_by; echo $article_author; 你可以这样试试 //this method of getting reques

如何在Joomla 2.5中获得当前文章的作者姓名

我试着用这个密码,但它给了我号码

$id = JRequest::getInt('id');
$article =& JTable::getInstance('content');
$article->load($id);
$article_author = $article->created_by;
echo $article_author;
你可以这样试试

//this method of getting requested variable is deprecated 
$id = JRequest::getInt('id');

//use JFactory::getApplication()->input instead of JRequest::getInt()

$id = JFactory::getApplication()->input->getInt('id')
$article = JTable::getInstance('content');
$article->load($id);

//get user id which create the article
$created_user_id = $article->created_by;

//fetch user
$user = JFactory::getUser($created_user_id);
$article_author = $user->name;
echo $article_author;

希望这对您有所帮助。

不要忘记您不需要使用
&
;)请改为
JFactory::getApplication()->input->getInt('id')
,而不是
$id=JRequest::getInt('id')
。JRequest已弃用。