GithubHelp home page GithubHelp logo

technoquebecca / page_callouts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sypets/page_callouts

0.0 0.0 0.0 41 KB

TYPO3 extension for adding messages to page module for TYPO3 v12

License: Other

Shell 61.78% PHP 37.30% HTML 0.92%

page_callouts's Introduction

Why this extension?

Informational, warning and error messages are displayed as "callouts" in the page module for various reasons, for example:

  • info message if page is of type folder
  • warning message if there are elements with an invalid colpos ("unused elements")
  • a page was defined as a shortcut, but has a missing target

However, it is not easily possible for extensions to add callouts of their own.

This extension provides a hook to add additional messages.

How it works

This extension Xclasses the PageLayoutController of the TYPO3 core. The class is inherited and the method getHeaderFlashMessagesForCurrentPid() overriden.

All functions which use the hook are called and the additional messages rendered.

How to use the hook

Simple example:

ext_localconf.php:

// ...
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['Sypets/PageCallouts/Xclass/PageLayoutControllerWithMessages']['addFlashMessageToPageModule'][] =
    \Myvendor\MyExtension\Hooks\PageCalloutsHook::class;

ClassesHooksPageCalloutsHook.php:

<?php
declare(strict_types=1);
namespace Myvendor\MyExtension\Hooks;

use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper;

final class PageCalloutsHook
{
    public function addMessages(array $pageInfo): array
    {
        $pageId = (int) ($pageInfo['uid']);
        $doktype = (int) ($pageInfo['doktype'] ?? 0);

        if ($someCondition) {
            $title = 'Some title';
            $message = 'some message';
            return [
                'title' => $title,
                'message' => $message,
                'state' => InfoboxViewHelper::STATE_ERROR
            ];
        }
        return [];
    }
}

page_callouts's People

Contributors

marc-munos avatar sypets avatar taieb123 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.