Get the Category of Current Page - Joomla! Forum - community, help and support


i need way display category name on every article in section.  there easy way this?

i've been researching, find things related catid (which seems have disappeared in 1.5) , mainframe (which doens't seem help).

thanks!

had similar problem couple of days ago http://forum.joomla.org/index.php/topic,216820.0.html

here solution found (maybe there's better way):

code: select all

<?php
$db = &jfactory::getdbo();            
         
$option   = jrequest::getcmd('option');
$view   = jrequest::getcmd('view');

$temp   = jrequest::getstring('id');
$temp   = explode(':', $temp);
$id   = $temp[0];
                     
/* checking if making article page */
if ($option == 'com_content' && $view == 'article' && $id)
{            
   /* trying category title db */
   $db->setquery('select cat.title #__categories cat right join #__content cont on cat.id = cont.catid cont.id='.$id);   
   $category_title = $db->loadresult();
               
   /* printing category title*/
   if ($category_title)
   {
       echo $category_title;         
   }               
}
?>





Comments

Popular posts from this blog

DHT11 Time out error using v0.4.1library

Sketch upload fails with Java error (___REMOVE___/bin/avrdude)!

Arduino Uno + KTY81/210 temperature sensor