Skip to main content

Joomla Powers

Dynamic Joomla Class Referencing (JPK System)

Joomla Powers is JCBโ€™s intelligent system for referencing Joomla framework and CMS classes using dynamic placeholders, called JPKs (Joomla Power Keys). These keys abstract the actual namespace of a Joomla class โ€” and JCB will automatically replace them with the correct use statement and fully qualified class path during compilation, based on the Joomla version you're targeting.

This means you can build components for Joomla 3, 4, 5 (and even 6) without manually managing class namespacing.

Why it Matters

Joomla's class namespaces change between versions (e.g. CMS vs Framework namespace shifts). Joomla Powers eliminates the need to write version-dependent code or maintain backward compatibility plugins by abstracting class references with tokens that are resolved automatically.

How It Works

You use a placeholder like this in your code:

{JPK\FormFieldText}

When compiling for Joomla 4, JCB will:

Add the correct use statement:

use Joomla\CMS\Form\Field\TextField;

Replace {JPK\FormFieldText} in your code with:

TextField (or a unique alias like CMSFormFieldTextField if needed)

All this happens automatically based on your selected Joomla version at compile time.

JPKs Can Resolve:

Core Joomla CMS classes

Joomla Framework classes

Custom user-defined aliases

Legacy classes (mapped per version)

Even your own Super Power classes, if properly defined in namespace maps

Features

Auto-resolves JPK tokens to correct class paths and use statements

Prevents duplicate class name collisions (adds โ€œasโ€ aliases if needed)

Version-aware logic: Joomla 3, 4, 5, and upcoming 6

JCB parses every file and injects correct classes

Fully traceable in compiler logs

Zero need for backward compatibility layers

Sample Use Case

You want to use Joomla's CategoryHelper class:

Instead of this:

use Joomla\CMS\Helper\CategoryHelper;

You write:

{JPK\HelperCategory}

And JCB will:

โœ… Inject the correct use statement
โœ… Replace the placeholder inline with the resolved class name
โœ… Ensure that same class doesnโ€™t collide with any other already-used alias

Conflict Avoidance

If multiple classes share the same base name, JCB automatically appends part of the namespace to avoid collisions:

use Joomla\CMS\Helper\CategoryHelper as CMSCategoryHelper;

Then replaces

{JPK\HelperCategory} โ†’ CMSCategoryHelper

Version-Specific Compilation

JPK mappings are stored per Joomla version. You can:

View/edit them via GUI (Joomla Powers panel)

Import/export updated mappings

Update JCB to get the latest mappings when Joomla releases updates

Best Practices

Use JPK tokens wherever Joomla classes are referenced

Keep your logic generic and version-safe

Check compiler logs if a class isn't resolving properly

Real Example

Write:

$field = new {JPK\FormFieldText};

JCB compiles to:

use Joomla\CMS\Form\Field\TextField;
$field = new TextField;
And on Joomla 5, it may compile to a newer namespace automatically.

Integration with Super Powers

You can reference Joomla Powers from inside Super Powers (PHP classes), templates, or any custom code area. The compiler handles everything dynamically.

Deployment Notes

All resolved classes are automatically included in compiled code

No runtime processing โ€” it's all handled at build-time

Compatible with CLI compilation and GitHub workflows

Summary

Joomla Powers (JPK system) is JCBโ€™s elegant, low-maintenance way to future-proof your component code. It ensures native compatibility with evolving Joomla APIs โ€” and lets you write cleaner, more maintainable extensions.