Woo*_*Dzu 17
很简单,如果您发送带有post/get的文章ID并使用变量"id"作为其编号:
$articleId = JRequest::getInt('id');
$db =& JFactory::getDBO();
$sql = "SELECT fulltext FROM #__content WHERE id = ".intval($articleId);
$db->setQuery($sql);
$fullArticle = $db->loadResult();
if(!strlen(trim($fullArticle))) $fullArticle = "Article is empty ";
Run Code Online (Sandbox Code Playgroud)
编辑:从任何地方获取articleId:
$articleId = (JRequest::getVar('option')==='com_content' && JRequest::getVar('view')==='article')? JRequest::getInt('id') : 0;
Run Code Online (Sandbox Code Playgroud)
尝试这种技术:
$article = JControllerLegacy::getInstance('Content')->getModel('Article')->getItem($articleId);
echo $article->introtext;
Run Code Online (Sandbox Code Playgroud)
按照Joomla 2.5中的文章ID获取文章文本(3也将根据文档工作)插件:
$article =& JTable::getInstance("content");
$article->load($id);
$content = '<h3>'. $article->get("title").'</h3>';
$content .= $article->get("introtext"); // introtext and/or fulltext
Run Code Online (Sandbox Code Playgroud)
文章ID来自组件/插件参数,例如:
从内部组件:
$app = JFactory::getApplication();
$params = $app->getParams();
$param = $params->get('terms_article_id');
Run Code Online (Sandbox Code Playgroud)从其他组成部分:
$params = JComponentHelper::getParams('com_mycom');
$id = $params->get('terms_article_id');
Run Code Online (Sandbox Code Playgroud)从模板的php文件中获取模块参数:
$module = JModuleHelper::getModule('mod_mymodule');
$params = new JRegistry($module->params); // or $mymoduleParams if few used
$id = (int) $headLineParams['count'];
Run Code Online (Sandbox Code Playgroud)