如何使用ajax获取joomla内容?(我想在弹出窗口中显示特定页面的内容),这是我的代码:(由 ajax 调用)
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
if ($option=="com_content" && $view=="article") {
$ids = explode(':',JRequest::getString('id'));
$article_id = $ids[0];
$article =& JTable::getInstance("content");
$article->load($article_id);
echo '<h2>'.$article->get("title").'</h2>';
echo $article->get("introtext"); // and/or fulltext
}
这仅适用于工件,但问题是例如我想显示类别或组件时
请查看您的 if 条件,它检查选项是否等于 com_content 和视图是否仅等于文章。如果视图包含类别,则它不起作用。因此,在 if 语句中添加条件,以便执行代码。对于类别,您还需要为其他组件添加视图=类别和喜欢。