我是joomla的新手。在我的模块中,我必须提供选择类别选项。我尝试通过以下代码从后端获取类别名称,但它不起作用。编码..
$backId=$params->get('mycategory');
$db->setQuery('SELECT cat.title FROM #__categories cat RIGHT JOIN #__content cont ON cat.id = cont.catid WHERE cont.id='.$backId);
$category_title = $db->loadResult();
if ($category_title)
{
echo $category_title;
}
如何获得我选择的类别名称。谢谢......
答案 0 :(得分:2)
希望这可能有用..
$db = JFactory::getDbo();
$id = jrequest::getint('id');
//match id to cat.id from _categories set to variable $id
$db->setQuery("SELECT cat.title FROM #__categories cat WHERE cat.id='$id'");
$category_title = $db->loadResult();
echo "$id";
echo "$category_title";