8

I have a thirdparty component which stores its categories in #__categories table.

-----+----------------+-----------------------+-----------------------+-----
...  | extension      | title                 | alias                 | ...
-----+----------------+-----------------------+-----------------------+-----
...  | com_content    | Uncategorised         | uncategorised         | ...
-----+----------------+-----------------------+-----------------------+-----
...  | com_banners    | Sample Data-Banners   | sample-data-banners   | ...
-----+----------------+-----------------------+-----------------------+-----
...  | com_newsfeeds  | Sample Data-Newsfeeds | sample-data-newsfeeds | ...
-----+----------------+-----------------------+-----------------------+-----
...  | com_contact    | Sample Data-Contact   | sample-data-contact   | ...
-----+----------------+-----------------------+-----------------------+-----
...  | com_content    | Joomla!               | joomla                | ...
-----+----------------+-----------------------+-----------------------+-----
...  | com_thirdparty | ThirdParty Category   | thridparty-category   | ...
-----+----------------+-----------------------+-----------------------+-----
...  | ...            | ...                   | ...                   | ...
-----+----------------+-----------------------+-----------------------+-----

I can print categories from com_banners or from other core components as below,

$categories = JCategories::getInstance('Banners');
$subCategories = $categories->get()->getChildren(true);
print_r($subCategories);

But it shows

"Fatal error: Class 'ThirdPartyCategories' not found in ...\libraries\legacy\categories\categories.php on line 152"

when trying to print the categories of another extension as below,

$categories = JCategories::getInstance('ThirdParty');
$subCategories = $categories->get()->getChildren(true);
print_r($subCategories);

What do I have to do with the legacy categories in joomla libraries ?

Note: The name ThirdParty is just a placeholder, could be any third party extension's name.

  • Is ThirdParty the actual name of the component? – Lodder Oct 14 '15 at 9:41
  • No, it's just a placeholder, could be any third party extension's name. In my case, it's com_thirdparty – kolunar Oct 14 '15 at 10:05
6

After doing some research, it turns out that the third party component I am using doesn't have a file created as ..\components\com_thirdparty\helpers\category.php which is required to implement a class ThirdPartyCategories which extends JCategories in the component's helpers directory as described below

defined('_JEXEC') or die;

/**
 * ThirdParty Component Category Tree
 */
class ThirdPartyCategories extends JCategories
{
    /**
     * Constructor
     *
     * @param   array  $options  Array of options
     */
    public function __construct($options = array())
    {
        $options['table']      = '#__thirdparty';
        $options['extension']  = 'com_thirdparty';
        $options['statefield'] = 'published';
        parent::__construct($options);
    }
}
  • If you've suitably answered you own question, please set it as your chosen answer to remove it from the unanswered questions list. – garth Dec 9 '15 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.