Skip to content

Conversation

@shahzan01
Copy link
Collaborator

@shahzan01 shahzan01 commented Aug 11, 2025

PR: Extend OpenGraph with Custom Field Mapping & Developer Interface

Description

This PR introduces custom field support for OpenGraph in the jacademy25_seo project.
It allows administrators to map Joomla custom fields into OpenGraph metadata and provides developers with a clear interface to make their custom fields OG-aware.

Key Features

  1. Custom Field Mapping in Categories

    • Category edit form now includes an OpenGraph tab where admins can map custom fields to:
      • og:title
      • og:description
      • og:image
      • og:image:alt
    • Mapped custom fields become the source for OG metadata whenever menu or article overrides are not provided.
  2. Built-In Grouping for Field Types

    • Custom fields can be grouped by their intended use:
      • TEXT → title, description
      • IMAGE → images for previews
      • IMAGE_ALT → alt text for accessibility and SEO
  3. Developer Extension via OpenGraphMappableFieldInterface
    Developers can expose their custom fields to the OpenGraph system with minimal effort:

    • Step 1: Extend your field class with OpenGraphMappableFieldInterface.
    • Step 2: Implement the getOpengraphGroup() function.
    • Step 3: Return the correct group (TEXT, IMAGE, or IMAGE_ALT) depending on your field type.

    Example:

    class MyCustomField extends \Joomla\CMS\Field\TextField implements OpenGraphMappableFieldInterface
    {
        public function getOpengraphGroup(): string
        {
            return 'TEXT'; // or IMAGE / IMAGE_ALT
        }
    }

@shahzan01 shahzan01 force-pushed the opengraph/custom-field branch from 42d1b1b to ef18543 Compare August 11, 2025 14:52
bembelimen added a commit that referenced this pull request Sep 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants