Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Joomla plugin : how to get article title and article id

I have developed on simple plugin in Joomla 1.6 I stuck at : How to get article title and article url.

I am getting no output if tried to print below statement:

echo $article->title;
echo $article->id;

I have written this in php file, not used MVC architecture. Is there any other settings need to do in Joomla admin side ?

Please suggest your pointers for extracting article title and article url.

Thanks in advance!

Pravin

like image 696
pravin Avatar asked Nov 30 '22 16:11

pravin


2 Answers

In order to get the article ID you have to write the following:

echo JRequest::getVar('id');

For the title, you just take the id you got, load the article object

$blabla = $article->load(ID);
echo $blabla->get('title');
like image 130
Asaf Avatar answered Dec 06 '22 05:12

Asaf


It seems JRequest is deprecated in 2.5 & 3.x as indicated in the Deprecated Elements list.

I would rather use the following:

$article_id = JFactory::getApplication()->input->get('id');
like image 26
Anriëtte Myburgh Avatar answered Dec 06 '22 05:12

Anriëtte Myburgh