php - Joomla, how to display category name in module latest -
i've been trying display category name after contents of 'latest' module in joomla.
i've made query in phpmyadmin , works. when try use in php module template page page stops @ point php should start.
$db = &jfactory::getdbo(); $id = jrequest::getstring('id'); $db->setquery("select `title` `#__categories` `id` = " .$item->catid); $category = $db->loadresult(); echo $category;
when replace $item->catid fixed number, works in phpmyadmin. can tell me go wrong?
thanks
$item having category title no need through db query. can in tmpl file. can category using $item->category_title
<ul class="latestnews<?php echo $moduleclass_sfx; ?>"> <?php foreach ($list $item) : ?> <li itemscope itemtype="http://schema.org/article"> <a href="<?php echo $item->link; ?>" itemprop="url"> <span itemprop="name"> <?php echo $item->title; ?>- <b><?php echo $item->category_title; ?></b> </span> </a> </li> <?php endforeach; ?> </ul>
update: if want display asked in comments need this
<ul class="latestnews<?php echo $moduleclass_sfx; ?>"> <?php foreach ($list $item) : ?> <li itemscope itemtype="http://schema.org/article"> <a href="<?php echo $item->link; ?>" itemprop="url"> <span itemprop="name"> <?php echo $item->title; ?> </span> </a> </li> <?php endforeach; ?> <b><a href="<?php jroute::_("index.php?option=com_content&view=category&layout=$item->category_title&id=$item->catid"); ?>">click here more news on ("<?php echo $item->category_title; ?>")</a></b> </ul>
Comments
Post a Comment