在Joomla 2.5中获取作者姓名
如何在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
$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已弃用。