esedic
6/13/2016 - 10:35 AM

Get Joomla article/category title

Get Joomla article/category title

<?php
	
	// get article title
	$input = JFactory::getApplication()->input;
	$id = $input->getInt('id');
	$article = JTable::getInstance('content');
	$article->load($id);
	echo $article->get('title');
	// or
	echo $article->title;

	// get category title v1
	$input = JFactory::getApplication()->input;
	$catid = $input->getInt('id');
	$category = JTable::getInstance('category');
	$category->load($catid );
	echo $category->get('title');
	// or
	echo $category->title;

	// get category title v2
	$input = JFactory::getApplication()->input;
	$cmodel = JModelLegacy::getInstance('Article', 'ContentModel');
	$catid = $cmodel->getItem($input->get('id'))->catid;
	$category = JTable::getInstance('category');
	$category->load($catid );
	echo $category->get('title');
	// or
	echo $category->title;

?>