Content
Content and form events in NorrCompetition leverage core Joomla 5 event classes. These events allow plugins to manipulate XML form structures before display and render custom markup on entry pages.
onContentPrepareForm
Event Class:
\Joomla\CMS\Event\Model\PrepareFormEventTriggered In: Form models during
loadForm()in backend and frontend.
Description
Triggered whenever a form definition is loaded. Plugins can inject custom XML fields, manipulate fieldsets, or alter field attributes conditionally before the form renders.
use Joomla\CMS\Event\Model\PrepareFormEvent;
public function onContentPrepareForm(PrepareFormEvent $event): void
{
$form = $event->getForm();
$data = $event->getData();
// Check target form context
if ($form->getName() !== 'com_competition.appform') {
return;
}
// Load custom XML definitions or alter existing fields
$form->load('<?xml version="1.0" encoding="utf-8"?><form><fieldset name="custom"><field name="my_extra" type="text" label="Extra Field" /></fieldset></form>');
}Available Form Contexts:
com_competition.competition— Backend contest edit formcom_competition.participant— Backend participant entry edit formcom_competition.category— Category edit formcom_competition.field— Custom field edit formcom_competition.appform— Frontend entry submission formcom_competition.cform— Frontend contest creation form
onContentPrepare
Event Class:
\Joomla\CMS\Event\Content\ContentPrepareEventContext:
com_competition.participantTriggered In: Frontend Entry view (
site/src/View/Participant/HtmlView.php)
Description
Allows plugins to process text shortcodes or enrich the entry object before rendering. Commonly used to parse plugin tags (e.g., {youtube}, {loadposition}) or generate links to contestant profiles.
onContentAfterTitle
Event Class:
\Joomla\CMS\Event\Content\ContentAfterTitleEventContext:
com_competition.participantTriggered In: Entry layout right after the title heading
Description
Returns HTML content to display immediately beneath the entry's main title (e.g., social share buttons, author badges, rating stars).
onContentBeforeDisplay
Event Class:
\Joomla\CMS\Event\Content\ContentBeforeDisplayEventContext:
com_competition.participantTriggered In: Entry layout directly above the media gallery / main body
Description
Returns HTML content to render above the primary entry media container.
onContentAfterDisplay
Event Class:
\Joomla\CMS\Event\Content\ContentAfterDisplayEventContext:
com_competition.participantTriggered In: Entry layout directly below the main body content
Description
Returns HTML markup rendered below the main entry body and custom fields (e.g., donation widgets, sponsor banners, related entry sliders).
Last updated