[SOLVED] How to display data of main category in item view

More
2 years 10 months ago - 2 years 10 months ago #56768 by iamrobert
Hi,

In my item template I want to display the main category title only.

I have tried this - but it echos both categories and a link:

Categories:
<?php echo $item->fields['categories']->display;?>

I can show main catid:
<?php echo $item->catid;?>

But how do I show Main Category Title?

I'm trying to build the redbox that says "Road Wheels":
taichungdesigner.com/t2015/comp2/index.html

Thanks,

Robert
Last edit: 2 years 10 months ago by ggppdk.

Please Log in or Create an account to join the conversation.

More
2 years 10 months ago - 2 years 10 months ago #56780 by ggppdk
Hello

you can use functionality of Joomla "JCategories" class
$cats_obj = JCategories::getInstance('Content');  // Create an instance of the class
$maincat_obj = $cats_obj->get($item->catid);     // Get the desired category
echo $maincat_obj->title;


-- FLEXIcontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!
Last edit: 2 years 10 months ago by ggppdk.

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
© 2018 Flexicontent. All Rights Reserved.