> For the complete documentation index, see [llms.txt](https://docs.norrnext.com/norrcompetition/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.norrnext.com/norrcompetition/customisation/events/content.md).

# 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\PrepareFormEvent`
* **Triggered 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.

```php
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 form
* `com_competition.participant` — Backend participant entry edit form
* `com_competition.category` — Category edit form
* `com_competition.field` — Custom field edit form
* `com_competition.appform` — Frontend entry submission form
* `com_competition.cform` — Frontend contest creation form

***

### `onContentPrepare`

* **Event Class:** `\Joomla\CMS\Event\Content\ContentPrepareEvent`
* **Context:** `com_competition.participant`
* **Triggered 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](/norrcompetition/customisation/link-to-contestant.md).

```php
use Joomla\CMS\Event\Content\ContentPrepareEvent;

public function onContentPrepare(ContentPrepareEvent $event): void
{
    if ($event->getContext() !== 'com_competition.participant') {
        return;
    }

    $item   = $event->getItem();
    $params = $event->getParams();

    // Process shortcodes or set dynamic properties
    $item->text = str_replace('{my_tag}', '<strong>Custom Value</strong>', $item->text ?? '');
}
```

***

### `onContentAfterTitle`

* **Event Class:** `\Joomla\CMS\Event\Content\ContentAfterTitleEvent`
* **Context:** `com_competition.participant`
* **Triggered 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).

```php
use Joomla\CMS\Event\Content\ContentAfterTitleEvent;

public function onContentAfterTitle(ContentAfterTitleEvent $event): string
{
    if ($event->getContext() !== 'com_competition.participant') {
        return '';
    }

    return '<div class="custom-badge">Verified Entry</div>';
}
```

***

### `onContentBeforeDisplay`

* **Event Class:** `\Joomla\CMS\Event\Content\ContentBeforeDisplayEvent`
* **Context:** `com_competition.participant`
* **Triggered In:** Entry layout directly above the media gallery / main body

#### Description

Returns HTML content to render above the primary entry media container.

```php
use Joomla\CMS\Event\Content\ContentBeforeDisplayEvent;

public function onContentBeforeDisplay(ContentBeforeDisplayEvent $event): string
{
    if ($event->getContext() !== 'com_competition.participant') {
        return '';
    }

    return '<div class="alert alert-info">Special Contest Notice</div>';
}
```

***

### `onContentAfterDisplay`

* **Event Class:** `\Joomla\CMS\Event\Content\ContentAfterDisplayEvent`
* **Context:** `com_competition.participant`
* **Triggered 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).

```php
use Joomla\CMS\Event\Content\ContentAfterDisplayEvent;

public function onContentAfterDisplay(ContentAfterDisplayEvent $event): string
{
    if ($event->getContext() !== 'com_competition.participant') {
        return '';
    }

    return '<div class="sponsor-footer">Sponsored by Partner</div>';
}
```
