I'm writing a Joomla! module in which I need to display current article title.
I've got this code found somewhere here on a stackoverflow:
<?php
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$ids = explode(':',JRequest::getString('id'));
$article_id = $ids[0];
$article =& JTable::getInstance("content");
$article->load($article_id);
echo $article->get("title");
?>
Although it works, it uses deprecated class JRequest, because it's from Joomla 1.7 and I use 3.2.2. Can someone tell me how to rewrite it to be valid with Joomla 3.2 ?
You can use the following code which uses up to date coding standards:
$input = JFactory::getApplication()->input;
$id = $input->getInt('id'); //get the article ID
$article = JTable::getInstance('content');
$article->load($id);
echo $article->get('title'); // display the article title
Hope this helps