Skip to content

Repository files navigation

Kumar Content Diff

Open-source Magento 2 module for CMS Page and CMS Block version history, comparison and restore.

Kumar Content Diff automatically creates version history for CMS Pages and CMS Blocks when their content changes. It allows administrators to view previous versions, compare changes between versions, restore previous content and manage version retention directly from the Magento Admin Panel.

Features

  • Enable/disable automatic versioning from Admin configuration.
  • Automatic version creation when CMS content changes.
  • Prevent duplicate versions when no content changes are detected.
  • Retain 1–5 versions per CMS entity; default is 2.
  • Separate CMS Page and CMS Block version history.
  • CMS Page and CMS Block history grids.
  • Version identifiers displayed as identifier-vN in the history UI.
  • Stores a complete snapshot of the CMS entity for each retained version.
  • Preserves CMS store assignments in the version snapshot.
  • "View" action to inspect a stored version.
  • "What Changed" field-level comparison between versions.
  • Shows old and new values for changed fields.
  • Restore an old snapshot into the live CMS entity.
  • Restore creates a new version instead of modifying historical data.
  • Automatic retention cleanup.
  • Clean all module history without changing live CMS content.
  • Displays version status such as current and previous.
  • Records version creation date.
  • Records the administrator who created the version when available.
  • Admin ACL permissions.
  • Uses Magento's native configuration and admin functionality.
  • No Magento core file modifications.
  • No bundled third-party libraries.

How It Works

When a CMS Page or CMS Block is saved:

CMS Entity Save
      ↓
Check Content Diff Configuration
      ↓
Create Content Snapshot
      ↓
Compare With Latest Version
      ↓
Content Changed?
   ┌──────┴──────┐
   │             │
  No            Yes
   │             │
   ↓             ↓
No Version    Create New Version
                 ↓
          Store Snapshot
                 ↓
          Apply Retention

If the content has not changed, no new version is created.

If the content has changed, a new version is stored automatically.

Version History

Each CMS entity maintains its own version sequence.

Example:

Home Page

Version 1
Version 2
Version 3
Version 4

The original CMS identifier remains unchanged.

For example:

Identifier:

home

The history UI can represent the versions as:

home-v1
home-v2
home-v3
home-v4

The version label is used for history identification and does not replace the original CMS identifier.

CMS Pages

CMS Page versions are available from:

Content > Content Diff > CMS Pages

The history grid provides information such as:

ID Identifier Title Version Status Created By Created At Actions

Available actions include:

View
What Changed
Restore
CMS Blocks

CMS Block versions are available from:

Content > Content Diff > CMS Blocks

CMS Blocks maintain their own independent version history.

For example:

Footer Block

Version 1
Version 2
Version 3

CMS Page and CMS Block versions are stored separately.

What Changed

The What Changed action compares two versions of the same CMS entity.

Example:

Version 2 → Version 3

The comparison identifies fields whose values have changed.

The comparison displays:

Field

Old Value
Version 2

New Value
Version 3

For example:

content

Version 2 — Old Value
---------------------
Welcome to our website.

Version 3 — New Value
---------------------
Welcome to our new website.

This provides a simple way to identify changes between CMS versions.

View Version

The View action allows administrators to inspect a stored version snapshot.

Viewing a version does not modify the live CMS entity.

Historical version data can be reviewed without changing:

CMS Page content. CMS Block content. CMS identifier. Store assignments. Current live content. Restore

The Restore action allows administrators to restore a previously stored version.

For example:

Current:

Version 1
Version 2
Version 3
Version 4
Version 5

If Version 3 is restored:

Version 1
Version 2
Version 3
Version 4
Version 5
Version 6 ← Restored content

The restored content becomes a new version.

Historical versions are not overwritten or modified.

This preserves the version history and provides a continuous record of changes.

Version Retention

The module supports configurable version retention.

Available values:


1
2
3
4
5

Default:

2

Retention is applied independently to each CMS Page or CMS Block.

For example, with retention configured to 2:

Version 1
Version 2
Version 3
Version 4

Only the latest two versions are retained:

Version 3
Version 4

Older versions are automatically removed.

Installation

Install the module using Composer:

composer require kumar/module-content-diff

Enable the module:

php bin/magento module:enable Kumar_ContentDiff

Run Magento setup:

php bin/magento setup:upgrade

Flush the cache:

php bin/magento cache:flush

For production mode, run the normal Magento deployment and compilation commands required by your environment.

Manual Installation

Copy the module to:

app/code/Kumar/ContentDiff

Then run:

php bin/magento module:enable Kumar_ContentDiff
php bin/magento setup:upgrade
php bin/magento cache:flush

Configuration

Configuration is available from:

Stores > Configuration > Kumar > Content Diff

Available settings:

Enabled

Enable or disable automatic CMS Page and CMS Block versioning.

Enabled
    Yes / No

When disabled, Magento CMS functionality continues to work normally, but new Content Diff versions are not created.

Version Retention

Controls the maximum number of versions retained for each CMS entity.

1–5

Default:

2

Clean All Version Data

Removes all stored Content Diff history.

This action does not delete or modify live CMS Pages or CMS Blocks.

For example:

Content Diff History
        ↓
    Clean All
        ↓
Version history removed

Live CMS Pages
        ↓
    Not affected

Live CMS Blocks
        ↓
    Not affected

Admin

CMS Page history:

Content > Content Diff > CMS Pages

CMS Block history:

Content > Content Diff > CMS Blocks

Configuration:

Stores > Configuration > Kumar > Content Diff

Permissions

The module integrates with Magento Admin ACL permissions.

Permissions are provided for areas such as:

Content Diff
├── CMS Pages
├── CMS Blocks
├── View Versions
├── Restore Versions
├── Clean Version Data
└── Configuration

This allows access to Content Diff functionality to be controlled through administrator roles.

Database

The module stores version history in its own database table:

kumar_cms_version

Version records contain information such as:

version_id
entity_id
entity_type
version
identifier
title
snapshot
store_ids
created_by
created_by_name
created_at
change_comment

The module does not use Magento's core CMS tables to store version history.

Snapshot

Each version stores a snapshot of the CMS entity.

A snapshot can contain information such as:

{
    "entity_type": "page",
    "entity_id": 1,
    "identifier": "home",
    "title": "Home Page",
    "fields": {
        "title": "Home Page",
        "identifier": "home",
        "content": "...",
        "is_active": "1",
        "page_layout": "1column"
    },
    "store_ids": [
        0,
        1
    ]
}

The exact snapshot fields can vary depending on the CMS entity and Magento version.

Store Assignments

CMS store assignments are included in the version snapshot.

This allows store assignments associated with a version to be preserved when restoring historical content.

Example:

Version 1

Stores:
Default Store View
Store View A

Data Safety

Kumar Content Diff keeps historical version data separate from the current CMS entity.

Viewing a version does not modify live content. Comparing versions does not modify live content. Cleaning version history does not delete live CMS content. Restoring a version creates a new version. Existing historical versions are not overwritten by a restore operation. Compatibility

Designed for Magento 2.4.x.

The module currently targets Magento 2.4.8-p5 while avoiding release-specific APIs where practical.

Recommended environment:

Magento 2.4.x
PHP 8.1+
Composer 2.x

Test the module against the exact Magento patch level used by your project before production rollout.

Development

Clone the repository:

git clone https://github.com/mekkumar/module-content-diff.git

Enter the repository:

cd module-content-diff

For local Magento development, place the module under:

app/code/Kumar/ContentDiff

Then run:

php bin/magento module:enable Kumar_ContentDiff
php bin/magento setup:upgrade
php bin/magento cache:flush

Composer Package

Package name:

kumar/module-content-diff

Install using:

composer require kumar/module-content-diff

The package uses Magento's standard Composer module structure and registration mechanism.

Requirements

PHP 8.1 or higher.
Magento 2.4.x.
Composer 2.x.

The module uses Magento's native framework components and does not require additional third-party libraries.

No Core Modifications

Kumar Content Diff does not require modifications to Magento core files.

The module integrates with Magento through:

Observers
Controllers
Models
Resource Models
UI Components
Admin ACL
Magento Configuration
Dependency Injection
License

This project is released under the MIT License.

See the LICENSE file for the complete license text.

Disclaimer

This project is an independent open-source Magento 2 extension.

Magento and related product names are trademarks of their respective owners.

This module is not an official extension and is provided "as is" without warranty of any kind.

About

Magento 2 CMS Page and CMS Block versioning and content diff module

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages