我想通过从 joomla 模板传递文章 ID 来获取文章文本.
I want to get article text by passing article ID from the joomla template.
简单,提供您发送带有 post/get 的文章 id 并使用变量id"作为其编号:
Simple, providing you sending an article id with post/get and using variable "id" as its number:
$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 ";
从任何地方获取文章 ID:
to get articleId from anywhere:
$articleId = (JRequest::getVar('option')==='com_content' && JRequest::getVar('view')==='article')? JRequest::getInt('id') : 0;
这篇关于如何通过 Joomla 中的文章 ID 获取文章文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!