For content managers
Manage title, text, image, alt text, advantages, CTA buttons, grid columns and visual style without editing PHP or HTML.
Baby in Brazil CTA module
This document is the primary technical reference for mod_bib_cta. It explains how the Joomla module is wired, which files own which responsibilities, what each PHP method does, how administrator presets work, and what must be checked before distribution or Joomla Extensions Directory submission.
The original CTA was a static bottom block inside the Baby in Brazil gallery page. It had strong visual design, but it was tied to a single page, a gallery-* CSS namespace and hard-coded content. The module converts that static block into a reusable Joomla extension.
Manage title, text, image, alt text, advantages, CTA buttons, grid columns and visual style without editing PHP or HTML.
Extend layouts, partials, icons, presets and CSS variables without copying whole CTA sections into template overrides.
Keep the module installable, documented, licensed and prepared for future public distribution requirements.
| Layer | Files | Responsibility |
|---|---|---|
| Manifest | mod_bib_cta.xml | Declares module metadata, files, media assets, language packs, fieldsets and administrator fields. |
| DI provider | services/provider.php | Registers the module dispatcher with Joomla dependency injection. |
| Dispatcher | src/Dispatcher/Dispatcher.php | Normalises layout selection and prepares display data before Joomla includes the selected module template. |
| Helper | src/Helper/CtaHelper.php | Central validation, normalisation, presets, CSS variables, escaping and icon rendering. |
| Admin field | src/Field/FeaturepresetField.php | Renders preset action buttons and injects admin preset payload/JavaScript. |
| Main templates | tmpl/*.php | Define high-level layout variants: default, compact, centered and dark. |
| Partial layouts | layouts/cta/*.php | Reusable render fragments for media, content, features, actions and decoration. |
| Assets | media/css/cta.css media/js/admin-feature-presets.js media/joomla.asset.json | Frontend styling and administrator preset behavior. |
Template files should not parse raw module params. They receive a normalised $cta array and pass it to smaller layouts.
The $cta array is produced by CtaHelper::getCtaData(). Keep this structure stable when extending the module; templates and partial layouts depend on it.
$cta = [
'id' => 'mod-bib-cta-123',
'moduleId' => 123,
'preset' => 'birth',
'variant' => 'default',
'ariaLabel' => 'Planning to give birth in Brazil',
'eyebrow' => '',
'title' => 'Planning to give birth in Brazil?',
'headingLevel' => 'h2',
'text' => 'We are here to make your journey safe...',
'media' => [
'src' => 'images/cta.jpg',
'alt' => 'Pregnant couple standing near the water',
'position' => 'left',
'fit' => 'cover',
'width' => 320,
'minHeight' => 224,
],
'features' => [
['enabled' => true, 'icon' => 'check', 'title' => 'Full Support', 'text' => 'Before & During', 'url' => ''],
],
'actions' => [
['enabled' => true, 'label' => 'Contact us', 'url' => 'https://...', 'style' => 'primary'],
],
'grid' => [
'mode' => 'exact',
'columns' => ['mobile' => 1, 'tablet' => 2, 'desktop' => 4, 'wide' => 4],
],
];
Registers the module dispatcher factory. Change this only when changing the dispatcher class or adding new services.
Calls the parent dispatcher, normalises the layout param, loads CSS assets and injects $cta into the layout data.
Converts the readable administrator layout value into the effective Joomla layout. Supports _custom and sanitises custom layout names.
Main data builder. Reads params, applies defaults, normalises media/features/actions/grid/design and returns the display contract.
Registers and loads mod_bib_cta.cta through Joomla Web Asset Manager when load_css is enabled.
Builds root CSS classes such as bib-cta--media-left, bib-cta--features-auto and bib-cta--dark.
Creates safe inline CSS variables for per-instance grid columns, media width, media height, gaps and container width.
Small utility for conditional class lists. Accepts keyed booleans and numeric class values.
Escapes text for HTML output. Use it in templates unless the value is already intentionally rendered as safe HTML.
Sanitises URLs before output. Internal anchors, relative URLs and external URLs are supported.
Detects whether a URL points outside the current site. Used for link behavior and rel/target decisions.
Returns inline SVG markup for supported icon identifiers. Keep icon options in forms and preset data synchronized with this method.
Frontend defaults for the whole CTA. Used when content fields are empty.
Payload for the administrator JavaScript that fills content fields when a content preset is applied.
Returns repeatable feature rows for a feature preset. These are inserted into the Joomla subform as real editable rows.
List of valid feature preset identifiers used by the admin field and validation logic.
Renders the three feature preset buttons: append, replace and clear. It also prints JSON options and a direct fallback script tag.
tmpl/default.php, compact.php, centered.php and dark.php decide the high-level shell and modifier classes.
layouts/cta/*.php render reusable pieces. The main templates should call these partials rather than duplicating markup.
| File | Purpose | Change when... |
|---|---|---|
| layouts/cta/media.php | Image or background media markup. | Need video support, picture sources or custom image wrapper. |
| layouts/cta/content.php | Eyebrow, title, text, features and actions composition. | Need different content order. |
| layouts/cta/features.php | Feature grid wrapper. | Need a different list/grid semantic structure. |
| layouts/cta/feature.php | One feature item. | Need custom icons, microcopy or link wrapping. |
| layouts/cta/actions.php | Button group wrapper. | Need different button grouping. |
| layouts/cta/action.php | One action button/link. | Need tracking attributes, analytics hooks or custom rel rules. |
| layouts/cta/decoration.php | Decorative line art. | Need another decorative SVG set. |
Feature presets intentionally use explicit actions. The select chooses a source; the buttons decide what happens.
Adds selected preset rows after existing feature rows. Existing rows are preserved.
Asks for confirmation when rows already exist, then clears the subform and inserts selected preset rows.
Asks for confirmation and removes all feature rows.
The frontend renders only saved repeatable rows. Presets are not dynamic frontend data sources; they are administrator data-entry accelerators.
The module is styled with a stable bib-cta namespace and per-instance CSS custom properties.
| Variable | Purpose |
|---|---|
--bib-cta-media-width | Left/right media column width. |
--bib-cta-media-min-height | Minimum media/card height. |
--bib-cta-feature-cols-mobile | Feature columns under tablet breakpoint. |
--bib-cta-feature-cols-tablet | Feature columns from 768px. |
--bib-cta-feature-cols-desktop | Feature columns from 992px. |
--bib-cta-feature-cols-wide | Feature columns from 1200px. |
--bib-cta-feature-min-width | Minimum item width for auto-fit feature grid mode. |
--bib-cta-content-gap | Vertical content spacing. |
--bib-cta-features-gap | Feature grid gap. |
Presets currently include birth, services, doctors, hospitals, documents, legal, concierge, apartments, family, newborn, gallery and contact.
When adding a new preset, update all of the following:
mod_bib_cta.xml — content and feature preset selects.CtaHelper::getPresetDefaults() — frontend fallback defaults.CtaHelper::getAdminContentPresetDefaults() — admin content-fill payload.CtaHelper::getFeaturePresetDefaults() — feature rows for insertion.Feature icons and action icons are defined by string identifiers, not by arbitrary SVG input. This keeps admin data safe and predictable.
| Type | Supported identifiers | Source of truth |
|---|---|---|
| Feature icons | check, heart, shield, doctor, hospital, document, home, apartment, family, baby, calendar, scale, suitcase, map, star, none | forms/feature.xml + CtaHelper::renderIcon() |
| Action icons | whatsapp, arrow, phone, mail, none | forms/action.xml + CtaHelper::renderIcon() |
This package includes a JED preparation checklist and update-server template. Before a public JED submission, the developer still needs to publish real project URLs, documentation URL, demo URL, support URL and update XML/download URL.
LICENSE.txt.dist/update-server/.docs/JED_SUBMISSION_GUIDE.html..php files.media/joomla.asset.json.admin-feature-presets.js.CHANGELOG.md, HTML docs and legacy Markdown docs when behavior changes.