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

More
8 years 7 months ago - 8 years 7 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:
Code:
<?php echo $item->fields['categories']->display;?>

I can show main catid:
Code:
<?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: 8 years 7 months ago by ggppdk.

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

More
8 years 7 months ago - 8 years 7 months ago #56780 by ggppdk
Hello

you can use functionality of Joomla "JCategories" class
Code:
$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...
Last edit: 8 years 7 months ago by ggppdk.

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

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.267 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline