1
Developer Guide
Jonathan Miller edited this page 2026-06-29 11:17:35 -05:00

Developer Guide

REST API

The Web Services plugin exposes OG tags via Joomla JSON:API. Full machine-readable spec: openapi.yaml.

Endpoints

Method URL Description
GET /api/index.php/v1/mokoog/tags List all OG tags
GET /api/index.php/v1/mokoog/tags/:id Get a single OG tag
POST /api/index.php/v1/mokoog/tags Create an OG tag
PATCH /api/index.php/v1/mokoog/tags/:id Update an OG tag
DELETE /api/index.php/v1/mokoog/tags/:id Delete an OG tag
GET /api/index.php/v1/mokoog/lookup/:content_type/:content_id Look up a tag by content

Authentication

All endpoints require Joomla API authentication (token or session) — the routes are registered as non-public.

Fields

Field Type Description
id int Primary key
content_type string e.g. com_content, menu, com_mokoshop
content_id int Content item ID
og_title string OG title
og_description string OG description
og_image string Image path
og_type string article, website, product, profile, book…
og_video string Video URL (YouTube/Vimeo/direct)
seo_title string Page <title> override (max 70)
meta_description string Meta description (max 200)
robots string Robots directives
canonical_url string Canonical URL (http/https)
event_data json Event schema fields (object/array)
recipe_data json Recipe schema fields (object/array)
custom_schema json Arbitrary schema.org JSON-LD (object/array)
language string Language tag (e.g. en-GB) or *
published int 0 or 1

JSON fields (event_data, recipe_data, custom_schema) must be JSON objects/arrays — scalars are rejected on save and via CSV import, and guarded on render.

Extending with Custom Plugins

onMokoOGAfterRender Event

Third-party plugins can subscribe to add custom social meta tags for any platform.

use Joomla\Event\Event;
use Joomla\Event\SubscriberInterface;

final class MyCustomSocialPlugin extends CMSPlugin implements SubscriberInterface
{
    public static function getSubscribedEvents(): array
    {
        return ['onMokoOGAfterRender' => 'onMokoOGAfterRender'];
    }

    public function onMokoOGAfterRender(Event $event): void
    {
        $doc   = $event->getArgument('subject');
        $image = $event->getArgument('image');

        // Add a Pinterest meta tag
        $doc->setMetaData('pinterest:media', $image);
    }
}

Event Arguments

Key Type Description
subject HtmlDocument The Joomla document object
title string Resolved OG title
description string Resolved OG description
image string Resolved image URL (absolute)
url string Current page URL
type string OG type (article, website, product…)
option string Component option (e.g. com_content, com_mokoshop)
view string View name (e.g. article, product)
id int Content item ID

MokoSuiteShop Integration

Product pages (com_mokoshop, view product) automatically receive:

  • og:type set to product
  • product:price:amount and product:price:currency meta tags
  • JSON-LD Product schema with offers, sku, and aggregateRating
  • Image auto-extracted from the linked #__content article

Product data is loaded from #__mokosuite_crm_products joined to #__content via article_id, with per-request caching.

Database Schema

Table: #__mokoog_tags — unique key (content_type, content_id, language). See Architecture for the full column list. Fresh installs build the complete schema from sql/install.mysql.sql; upgrades apply incremental sql/updates/mysql/*.sql scripts.

Forward Compatibility

The codebase is clean for Joomla 7: database access goes through Factory::getContainer()->get(DatabaseInterface::class), language/app via getApplication(), filesystem via Joomla\Filesystem\*, and controllers throw exceptions instead of jexit(). The CI "deprecated Joomla API" check passes with zero findings.

Testing

PHPUnit unit tests live under tests/Unit/ (pure helpers — JsonLdBuilder schema builders and toScriptTag() escaping). Run via vendor/bin/phpunit. CI runs the suite on every PR.