Skip to Content Skip to Menu

🌟Discover the Joomla AI Plugin that wrote its own story! - CB Editor Assistant 1.1now for Joomla 3, 4 & 5!
✍️ 5-Day Free Trial, then 🎯 save up to 30% with our 🛍️ Intro Offer (First 50 users, ends Dec. 25th)
🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

Ever wonder if you can design your Joomla components to work on any platform easily? You can actually, but keep note this requires Community Builder to be installed. You can include the CB API directly into your modules, components, or plugins. You will then have the power of CB API at your finger tips.

if ( ( ! file_exists( JPATH_SITE . '/libraries/CBLib/CBLib/Core/CBLib.php' ) ) || ( ! file_exists( JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php' ) ) ) {
	echo 'CB not installed'; return;
}

include_once( JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php' );

Now the above will give you access to many of the functions provided by the foundation and in most cases this is all you'll need. However if you want to use class functions and plugin functions or even database functions you need to follow the include with a cb import.

cbimport( 'cb.html' );

The above will give you remaining access to CBs APIs. New CBLib APIs however use autoloading and is recommended to use an editor that can provide autocomplete for ease of use. Additionally if you need language files loaded in at a specific location or early you can use the below.

cbimport( 'language.front' );

None of this will load in CBs styling however. So if you output fields directly after doing the above they will have no CSS styling if CB styling hasn't already loaded. To load in CBs template CSS file you have to call the following.

outputCbTemplate();

If also needing access to various plugin APIs you will also need to be sure plugins are loaded in. This can be done with the following.

global $_PLUGINS;

$_PLUGINS->loadPluginGroup( 'user' );