I want to get article text by passing article ID from the joomla template.
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 ";
EDIT: to get articleId from anywhere:
$articleId = (JRequest::getVar('option')==='com_content' && JRequest::getVar('view')==='article')? JRequest::getInt('id') : 0;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With