Swift
Swift

Reputation: 3

Joomla, how get component id in plugin using component name

I have created plugin in group content. Now i want to fetch component or extension id using component name.

I am using below code

$com_articles = JTable::getInstance( 'component');
$com_articles->loadByOption('com_directory');

But error log showing error

[09-Nov-2016 09:41:01 Etc/GMT] PHP Fatal error:  Call to a member function loadByOption() on boolean in /home/phprilpk/public_html/demo/refer/plugins/content/auto_menu/auto_menu.php on line 17

Upvotes: 0

Views: 544

Answers (1)

Nil
Nil

Reputation: 1193

Extensions are stored in prefix_extensions table in database. You can get extension data using jFactory::getDBO();

See this code.

$db = JFactory::getDBO();
$com_articles = $db->setQuery("SELECT * FROM #__extensions WHERE name = 'com_directory'");
$com_articles = $com_articles->loadObject();
print_r($com_articles);

Upvotes: 1

Related Questions