Clone
1
Developer-Guide
Jonathan Miller edited this page 2026-05-31 01:50:33 +00:00

Developer Guide

REST API

The Web Services plugin exposes OG tags via Joomla JSON:API.

Endpoints

Method URL Description
GET /api/v1/mokoog/tags List all OG tags
GET /api/v1/mokoog/tags/:id Get single OG tag
POST /api/v1/mokoog/tags Create OG tag
PATCH /api/v1/mokoog/tags/:id Update OG tag
DELETE /api/v1/mokoog/tags/:id Delete OG tag
GET /api/v1/mokoog/lookup/:content_type/:content_id Lookup by content

Authentication

All endpoints require Joomla API authentication (token or session).

Extending with Custom Plugins

onMokoOGAfterRender Event

Third-party plugins can subscribe to the onMokoOGAfterRender event 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');
        $title = $event->getArgument('title');
        $image = $event->getArgument('image');

        // Add 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, etc.)
option string Component option (e.g. com_content)
view string View name (e.g. article)
id int Content item ID

Content Type Adapters

To support OG auto-generation for custom content types, implement ContentTypeInterface:

interface ContentTypeInterface
{
    public function canHandle(string $option, string $view): bool;
    public function getContentType(): string;
    public function getTitle(int $id): string;
    public function getDescription(int $id): string;
    public function getImage(int $id): string;
}

Built-in adapters exist for K2, VirtueMart, and HikaShop.

Database Schema

Table: #__mokoog_tags

Column Type Description
id INT UNSIGNED Primary key
content_type VARCHAR(100) e.g. com_content, menu, com_content.category
content_id INT UNSIGNED ID of the content item
og_title VARCHAR(255) Custom OG title
og_description TEXT Custom OG description
og_image VARCHAR(512) Image path relative to JPATH_ROOT
og_type VARCHAR(50) article, website, product, etc.
seo_title VARCHAR(70) Custom page title override
meta_description VARCHAR(200) Custom meta description
robots VARCHAR(100) Robots directive
canonical_url VARCHAR(512) Canonical URL override
language CHAR(7) Language tag (e.g. en-GB) or *
published TINYINT(1) 0 or 1
created DATETIME Record creation time
modified DATETIME Last modification time

Unique key: (content_type, content_id, language)