What this solution does
The module automates the setup and management of the Open Graph protocol. It automatically populates key meta tags: og:title and og:description are pulled from the corresponding page fields, og:url points to the current address, and og:site_name displays the site name. For og:image, the module selects an image from the current element or section, determines its MIME type and dimensions, and generates a secure URL when HTTPS is used. Additional properties can be configured manually.
The module adds input fields for Open Graph data within the administrative interface for elements and sections. A default image for the entire site can be set. Data is cached to reduce server load. The system supports creating a list of excluded pages. The algorithm for selecting the og:image operates automatically, with the ability to define maximum dimensions and perform on-the-fly image resizing. Users can configure the priority order of value assignment algorithms. Available settings include cache lifetime, exclusion management, and the display of the Open Graph fields tab.
The Open Graph module by Dev2Fun provides automatic generation of meta-data for social networks and search engines. A dedicated tab with Open Graph fields is added to the section management interface for convenient configuration of images and text parameters. Users can flexibly adjust settings, including additional fields that comply with the official specification.
The data generation mechanism operates on a configurable hierarchical principle. By default, the system prioritizes values from Open Graph fields within elements and sections. If these are missing, data is filled from iblock fields. Next, empty fields are populated with values from page properties (SetPageProperty or SetDirProperty). Any remaining empty parameters are filled using the legacy default algorithm.
The module supports automatic image resizing. Users can set maximum width and height limits and select one of three standard resizing algorithms.
The Open Graph module automatically generates meta tags for social networks. If the og:image property is empty, the image configured in the admin panel settings is used.
To exclude specific pages from meta tag generation, specify their paths relative to the site root. Include the file extension in the path and exclude GET parameters. To exclude the main page, enter index.
Property configuration is performed on the element and section editing pages in the 'Open Graph Settings' tab.
Field population logic:
- og:title: If not set, the value from 'Element Name' (NAME) is used.
- og:description: If empty, 'Short Description' (PREVIEW_TEXT) is used. If that is also empty, 'Detailed Description' (DETAIL_TEXT) is used. The description length is automatically limited to 121 characters.
- og:image: When the og:image parameter is active and no manual image is specified, the system uses the image from PREVIEW_PICTURE. If that is missing, DETAIL_PICTURE is used.
The following properties are not available for user editing and are generated automatically:
og:url
og:site_name
og:image:type
og:image:width
og:image:height
og:image:secure_url
All other properties are configured in the component settings and output automatically.
To implement precise Open Graph integration for elements, add the required code to the result_modifier.php file of the template used by the component.
To implement precise Open Graph integration for sections, add the corresponding code to the result_modifier.php file of the component's template.
After making changes, clear the cache.
Support for setting Open Graph properties via SetPageProperty and SetDirProperty remains available but with reduced priority.
Processing logic (data is written only if the value is empty):
1. Search for data in elements or sections.
2. Search for data in SetPageProperty and SetDirProperty.
3. Set data from default values.
4. Wrap data into meta tags.
5. Output the meta tags.
Available events:
OnBeforeAddOpenGraph
Variables: &$arSettings (settings array), &$cache_id (cache identifier).
Description: Triggered before all data formation algorithms are executed.
OnAfterAddOgFields
Variables: &ogValues (array of fields with values).
Description: Triggered after the og_fields algorithm completes.
OnAfterAddIBlockFields
Variables: &ogValues (array of fields with values).
Description: Triggered after the iblock_fields algorithm completes.
The module provides events for automatically generating Open Graph data.
The OnAfterAddPropFields event with the ogValues parameter triggers after the prop_fields algorithm processes.
The OnAfterAdd event with the ogValues parameter runs after all algorithms complete.
The OnBeforeOutput event with the $arData parameter executes immediately before properties are rendered; this event is not cached.
Technical documentation and change discussions are available in the GitHub repository.
General iT can handle the implementation of “Open Graph - fast, easy, and automatic”, from installation to configuration and compatibility checks.