How can I get the category type using a Joomla category node?

2 years 2 months ago - 2 years 2 months ago #75103 by riiich
I have a Joomla category list called from SQL and need the FlexiContent 'type' of the category, for example...
...
$database = JFactory::getDBO();
$database->setQuery("SELECT * FROM #__categories WHERE parent_id=".$id." AND published = 1 ORDER BY lft");
$categories = $database->loadObjectList();
foreach ($categories as $category) {
  //$type = ...?
}
...

Is there a method I can call to get the Flexi field 'type' for the categories in the array? Or is there a way I can ammend the SQL call to obtain the type?

Thanks

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

2 years 2 months ago - 2 years 2 months ago #75104 by ggppdk
Hello

you can use the code that you are using in your example

To get Flexicontent category configuration you can
foreach ($categories as $category)
{
  $category->config = new JRegistry($category->params);
}
if you want to get item counts then you can use our global (Cached) variable $globalcats
it is cached because it contains also things like item counts that consider multi-category assignments, which can be a little heavy
e.g. 0.2 seconds in large websites,

please do not modify it
if you want to modify assign the array to a new variable
global $globalcats;
$cats = $globalcats;


-- 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!

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

2 years 2 months ago #75157 by riiich
Apologies for not replying. I found that categories don't store types (as far as I'm aware). So although I set the type on the category, the only place to get the value is to check an item inside the category for the 'type_id' field.

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

2 years 2 months ago #75161 by ggppdk
Hello

you mean that in types manager you have edited a type and limited the type to a specific category subtree ?


-- 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!

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

Moderators: vistamediajoomlacornerggppdk
© 2018 Flexicontent. All Rights Reserved.