Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get article text by article ID in Joomla?

Tags:

php

joomla

I want to get article text by passing article ID from the joomla template.

like image 407
Aryan G Avatar asked Aug 28 '11 08:08

Aryan G


1 Answers

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;
like image 158
WooDzu Avatar answered Sep 27 '22 16:09

WooDzu