PHPackages                             xima/xima-typo3-page-subscription - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. xima/xima-typo3-page-subscription

ActiveTypo3-cms-extension[Utility &amp; Helpers](/categories/utility)

xima/xima-typo3-page-subscription
=================================

This extension provides an update subscription functionality for frontend user regarding changes on content elements on a page.

v13.x-dev(2mo ago)071[1 PRs](https://github.com/xima-media/xima-typo3-page-subscription/pulls)GPL-2.0-or-laterPHPPHP ^8.1

Since Feb 26Pushed 1mo ago4 watchersCompare

[ Source](https://github.com/xima-media/xima-typo3-page-subscription)[ Packagist](https://packagist.org/packages/xima/xima-typo3-page-subscription)[ RSS](/packages/xima-xima-typo3-page-subscription/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (8)Versions (5)Used By (0)

[![Extension icon](Resources/Public/Icons/Extension.svg)](Resources/Public/Icons/Extension.svg)

TYPO3 extension `xima_typo3_page_subscription`
==============================================

[](#typo3-extension-xima_typo3_page_subscription)

![Supported TYPO3 versions](https://camo.githubusercontent.com/8b8a287362a6b52c4555645b513d4ce88c73b3bb15a61a478142db2019ebf375/68747470733a2f2f62616467656e2e6e65742f62616467652f5459504f332f31322f6f72616e6765)

This extension provides an update subscription functionality for frontend user regarding changes on content elements on a page.

> **Note:** This extension is still under development and not yet ready for production.

- [Principles](#principles)
    - [What does it do?](#what-does-it-do)
    - [What does it not do?](#what-does-it-not-do)
    - [Challenges](#challenges)
- [Requirements](#requirements)
- [Installation](#installation)
    - [Composer](#composer)
    - [Configuration](#configuration)
    - [Template](#template)
    - [Scheduler](#scheduler)
    - [Easy setup](#easy-setup)
- [Concept](#concept)
    - [JavaScript](#javascript)
    - [ViewHelper](#viewhelper)
    - [Interpreter](#interpreter)
    - [Console command](#console-command)
    - [Crawler](#crawler)
    - [Fingerprint](#fingerprint)
    - [Hash](#hash)
    - [Mailer](#mailer)
- [Thoughts](#thoughts)
- [ToDo](#todo)
- [Outlook](#outlook)
- [License](#license)

Principles
----------

[](#principles)

### What does it do?

[](#what-does-it-do)

- Subscribe as frontend user to a page
- Manage your subscriptions
- Get notified by mail about updates on subscribed pages
    - Informing about new or changed content elements
- Providing a console command for checking updates
- Providing a crawler for fetching content elements
- Support partly subscriptions for single content elements

### What does it not do?

[](#what-does-it-not-do)

- Providing detailed information about changed fields
- Informing about deleted content elements

### Challenges

[](#challenges)

- Keeping **dynamic elements** on a page in mind, e.g. all entries of a news teaser list, which are basically not referenced on the coressponding page
- Finding all content data which are **relevant for the frontend** (not every update is a relevant change for a frontend user)

Requirements
------------

[](#requirements)

- TYPO3 &gt;= 12.4 &amp; PHP 8.1+

Installation
------------

[](#installation)

### Composer

[](#composer)

```
composer require xima/xima-typo3-page-subscription
```

### Configuration

[](#configuration)

Include the static TypoScript template "Page subscription" or directly import it in your sitepackage:

```
@import 'EXT:xima_typo3_page_subscription/Configuration/TypoScript/setup.typoscript'

```

See the extension settings in the TYPO3 backend for further configuration.

### Template

[](#template)

Add the surrounding `xtps:updateInformation` viewhelper to your templates, e.g. to a general layout file.

### Scheduler

[](#scheduler)

Install the scheduler task for the console command `page-subscription:check-updates` in the TYPO3 backend.

### Easy setup

[](#easy-setup)

ToDo

Concept
-------

[](#concept)

The general workflow is as follows:

[![Mail](./Documentation/page-subscription-concept.svg)](./Documentation/page-subscription-concept.svg)

1. Frontend user is logged in
2. User subscribes to a page
3. Content of subscribed page is edited by a backend user
4. Scheduler tasks runs in period and checks for updates
5. Frontend user gets notified by mail

The technical implementation is based on the following concepts:

### JavaScript

[](#javascript)

Use the `PageSubscription` class to handle the subscription of pages in the frontend. Example below:

```
import PageSubscription from '../path/to/extension/xima_typo3_page_subscription/Resources/Public/JavaScript/PageSubscription.js';

const toggleButton = document.querySelector('.toggle-subscription');
toggleButton.addEventListener("click", async function(){
    const data = await PageSubscription.toggle(this, PageSubscription.Type.Subscription, this.element.getAttribute('data-page-subscription-pid'));
    if (data.result == true) {
        this.classList.add('subscribed');
    } else {
        this.classList.remove('subscribed');
    }
});
```

### ViewHelper

[](#viewhelper)

```

```

> The viewhelper only occurs in the dom when crawler is active and renders a surrounding div with the metadata attributes around the content element.

### Interpreter

[](#interpreter)

Interpreter are used to build metadata information for the view helper and generate target links.

The following interpreters are available:

- [ContentInterpreter](Classes/Interpreter/ContentInterpreter.php)
- [ContentBlockInterpreter](Classes/Interpreter/ContentBlockInterpreter.php)
- [FileInterpreter](Classes/Interpreter/FileInterpreter.php)
- [NewsInterpreter](Classes/Interpreter/NewsInterpreter.php)

Create custom interpreter using the [InterpreterInterface](Classes/Interpreter/InterpreterInterface.php) and register the new interpreter in your `ext_localconf.php` (example below):

```
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['xima_typo3_page_subscription']['registerInterpreter'][\TYPO3\CMS\Core\Resource\File::class] = \Xima\XimaTypo3PageSubscription\Interpreter\FileInterpreter::class;
```

### Console command

[](#console-command)

The console command checks all subscriptions for updates and starts the crawling process:

```
./vendor/bin/typo3 page-subscription:check-updates
```

> See help for more options.

### Crawler

[](#crawler)

The crawler runs through all subscriptions and fetches the content of all occuring `xtps:updateInformation` viewhelper elements in the frontend.

> For crawling the uncached content, a middleware is used to disable the cache for the crawler request.

After that, the saved hashes of the subscription will be compared with the new ones and the subscribers will be notified by mail.

### Fingerprint

[](#fingerprint)

The page fingerprint is a collection of hashes of all relevant content elements on a page. A hierarchy of elements is supported.

```
{"tt_content--textmedia--89":
  {
    "hash":"4f4b94deb5adbc50f63059ba9169bbde",
    "children":[]
  }
}
```

The content hierarchy is desired for e.g. dynamic elements within a plugin. Both of them can be updated individually, but the relation between them should be kept. Therefore a structure like the following will be generated as fingerprint:

- Header
- Textmedia
- News plugin
    - News entry
    - News entry
    - News entry
- Teaser

### Hash

[](#hash)

The hash is generated by the `HashGenerator` and uses the following parts of a content element:

- Textual data
- Image `src`
- Link `href`

The joined string is afterwards hashed with `md5`.

> This is to ensure that all content element data relevant to the frontend is taken into account for hashing.

If you want to add more fields to the hash, you can do this by using a desired data attribute `data-page-subscription-additional-data` within the content element or using the [HashGenerationModifyEvent](Classes/Event/HashGenerationModifyEvent.php):

```
