Getting the category title

Added by Jonathan Hack 364 days ago

Hi,

I just wanted to share a bit of code I added to my copy of artcats. The purpose is to return the title of the category. I put the following code in the params.php file at lines 412-421, just before the function getArticleID()

function getCategoryTitle()
{
$query = 'SELECT title' .
' FROM #__categories' .
' WHERE id = '. $this->getCategoryID();
$db =& JFactory::getDBO();
$db->setQuery($query);
return $db->loadResult();
}

I use this in order to change the title of the page when viewed in article mode. When using Mode=both I set the Articles Mode Title to '{catname} Services' and then I modified line 10 of menustyle.php to:

&lt;h3&gt;<?php echo str_replace('{catname}',$artcats->getCategoryTitle(),$params->get('articles_mode_title')); ?>&lt;/h3&gt;

The result is that a series of categories [Photography, Design, Web] turns into the following titles [Photography Services, Design Services, Web Services].

I would appreciate having this added to future releases. If it needs to be coded differently go ahead and I'll make my changes based on the first official release of this code.

Cheers!
Jonathan