Search code examples
joomlajoomla-template

Display category name in template


I am trying to display a category name in a module position.

I tried:

<?php echo $listing['Category']['title'];?>

It did not work.

I followed this link, but it shows the article title and I need the category one. I'm working on Joomla 1.7.


Solution

  • As per the posters comment in the OP:

    <?php 
        $db = &JFactory::getDBO(); 
        $id = JRequest::getString('id'); 
        $db->setQuery('SELECT #__categories.title FROM #__content, #__categories WHERE #__content.catid = #__categories.id AND #__content.id = '.$id); 
        $category = $db->loadResult();
        echo $category; 
    ?>