Skip to content

Commit

Permalink
[TASK] Updated documentation to replace the old urlToCheck hook with …
Browse files Browse the repository at this point in the history
…the new ModifyPreviewUrlEvent
  • Loading branch information
RinyVT committed Jan 28, 2025
1 parent 6fb98e6 commit 7e12065
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .ddev/commands/host/docs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

docker-compose -f .ddev/docker-compose.docs.yaml up docs
docker compose -f .ddev/docker-compose.docs.yaml up docs
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ We will follow [Semantic Versioning](http://semver.org/).

### Breaking
- Replaced the `urlToCheck` with a new `ModifyPreviewUrl` event
- TODO: Add documentation

### Changed
- Updated all the underlying Yoast libraries to the latest version
Expand Down
45 changes: 45 additions & 0 deletions Documentation/Configuration/Events/Index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.. include:: /Includes.rst.txt


.. _events:

Event
=====

Event to change the URL to analyse
---------------------------------
By default the extension is generating the URL to analyse based on the Site Configuration and configured Route Enhancers. In some cases
you want to change the URL that needs to be analysed. With the `ModifyPreviewUrlEvent`, you will be able to alter the URL that will be
used to analyse your content.

First you need to create an EventListener that will :

.. code-block:: php
<?php
namespace Vendor\Package\EventListener;
use YoastSeoForTypo3\YoastSeo\Event\ModifyPreviewUrlEvent;
final class ModifyPreviewUrlEventListener
{
public function __invoke(ModifyPreviewUrlEvent $event)
{
$url = $event->getUrl();
$site = $event->getSite();
$pageId = $event->getPageId();
$languageId = $event->getLanguageId();
// Create a new url based on your needs
$event->setUrl($newUrl);
}
}
After you created your event listener to alter the URL, you need to register it in your `Services.yaml`.

Check the TYPO3 documentation for your used TYPO3 version on how to register this correctly.

After you have registered the listener, you need to clear the TYPO3 cache through the `Maintenance` module
(or `vendor/bin/typo3 cache:flush`) before your code will be activated.
42 changes: 0 additions & 42 deletions Documentation/Configuration/Hooks/Index.rst

This file was deleted.

2 changes: 1 addition & 1 deletion Documentation/Configuration/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ However, a few things can still be configured using an extension that overwrites
SnippetPreview/Index
StructuredData/Index
OtherPlugins/Index
Hooks/Index
Events/Index

0 comments on commit 7e12065

Please sign in to comment.