Technical Library / Open Source

Joomla Snippets

Searchable collection of production-ready code recipes for template overrides, modules, plugins, and Joomla! 3 to 6 APIs.

100 Snippets
12 Categories
J3 to J6 Compatibility
Showing 4 of 100 snippets
JavaScript J6 J5 J4 Component
JavaScript, CSS and SEO

Make CSRF-Protected AJAX Calls with Native Joomla.request()

Sends asynchronous POST requests with automatic CSRF headers and JsonResponse parsing using Joomla native core wrapper.

async function sendVote(endpointUrl, itemId) {
  const token = Joomla.getOptions('csrf.token', '');
  const body  = new URLSearchParams({ id: String(itemId) });
  if (token) {
    body.set(token, '1');
  }

// ...
53 178
JavaScript J6 J5 J4 Template
JavaScript, CSS and SEO

Display Dynamic System Alerts via JavaScript with Joomla.renderMessages()

Renders native accessible alerts (success, warning, error, info) inside #system-message-container without a page reload.

// Exibe notificação de sucesso no container padrão do template
Joomla.renderMessages({
  success: ['Configurações salvas com sucesso!'],
});

// Limpa mensagens anteriores e exibe erro dentro de um container específico
Joomla.removeMessages(document.querySelector('#meu-form-alerts'));
// ...
39 134
PHP J6 J5 J4 Template Override
JavaScript, CSS and SEO

Inject Structured Schema.org JSON-LD into <head> via HtmlDocument

Outputs valid Article, FAQPage or SoftwareSourceCode structured data in application/ld+json for Google Rich Results.

<?php

declare(strict_types=1);

use Joomla\CMS\Factory;
use Joomla\CMS\Uri\Uri;

// ...
55 187
PHP J6 J5 J3 Template Override
JavaScript, CSS and SEO

Set Canonical Link, Open Graph and Twitter Cards Dynamically

Outputs rel="canonical", og:title, og:description, og:image and twitter:card cleanly through HtmlDocument for optimal SEO and sharing.

<?php

declare(strict_types=1);

use Joomla\CMS\Factory;
use Joomla\CMS\Uri\Uri;

// ...
60 202 2 versions
Direct Engineering

Have a Joomla project or technical challenge in mind?

From architectural diagnosis to production deployment, directly with the engineer.