Problems I Faced and My Evaluations!

I’d a requirement earlier to get tt_content data array inside FLUID template of extended fe_login. But it’s not there by default like any conventional TYPO3 content element or EXTBASE extension modules. I think about several methods to achieve this, here are the methods I tried and failed to achieve.

  • DataProcessors
  • TYPOSCRIPT Variables
  • ViewHelpers

All these methods failed and not effective. Finally, I fed up and gone through the implementation for XCLASS although it was not recommended. Finally I got a method to achieve my requirements. In TYPO3 if you’re using the fluid template extended then it throws an event from the event dispatcher through EXTBASE framework. You could get an idea what an event dispatcher looks like from the following documentation. https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Hooks/EventDispatcher/Index.html

So it was my first time using an event dispatcher even though I used Hooks and Signal Slots before in TYPO3 several times. When I went through the LoginController of fe_login I saw the code which shows an event is thrown from the controller. I thought it was something which is exactly the same as the signal slot dispatcher works. The implementation how it should work is explained below in the Solution section.

Solution

If you read the above section it’s mentioned that our hero of attraction is event dispatcher. Here is how it works. In core the event is thrown like below.

$this->eventDispatcher->dispatch(new ModifyLoginFormViewEvent($this->view));

So we need to invoke this event in our custom extension. Let’s say it’s something like site_package our custom extension. These are the steps for invoking the event.

Step 1: Create a file called Services.yaml inside the path EXT:site_package/Configuration/Services.yaml

Step 2: You need to configure your Event Listener class in the above created yaml file.

services:
  VendorName\SitePackage\EventListener\FeloginViewModifier:
    tags:
      - name: event.listener
        identifier: 'loginObjectIdentifier'
        event: TYPO3\CMS\FrontendLogin\Event\ModifyLoginFormViewEvent
        before: 'redirects, anotherIdentifier'

Here the identifier should be unique that’s it. You can check this whether the configuration has been added to the installation through TYPO3 Backend. In configuration module backend there is an option for viewing the event listeners PSR-14.

Backend Module Configuration

Step 3: Code Properly the EventListener Class for achieving whatever you need to achieve.

<?php
namespace VendorName\SitePackage\EventListener;

use TYPO3\CMS\FrontendLogin\Event\ModifyLoginFormViewEvent;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
 * Class FeloginViewModifier
 * @package VendorName\SitePackage\EventListener
 */
class FeloginViewModifier
{
    /**
     * @param ModifyLoginFormViewEvent $event
     */
    public function __invoke(ModifyLoginFormViewEvent $event): void
    {
        $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\Extbase\\Object\\ObjectManager');
        $configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager');
        $data = $configurationManager->getContentObject()->data;
        if (!empty($data) && $data['CType'] == 'felogin_login') {
            $ttContentUid = $data['uid'];
            $fileRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\FileRepository::class);
            $fileObjects = $fileRepository->findByRelation('tt_content', 'assets', $ttContentUid);
            $event->getView()->assign('ttContent', $data);
            $event->getView()->assign('assetFile', $fileObjects);
        }
    }
}

Now the assigned variables is available for you in your extended template. Cheers! If this vlog helped you I will be really happy. Looking forward to more subjects.

please comment your feedback.

My Blogs

Why TYPO3 is Enterprise CMS

Hi Guys,

I’ve checked different blogs explains the difference between several CMS Platforms with each one of its pros and cons. Here in my post I’m not trying to explain the positive sides of TYPO3 with any other CMS platform’s negative. This post showcase the key features of TYPO3 which may help to understand why this CMS different from other open-source platforms. Currently in market there are about 350 different CMS programs are available selecting the best one from these is based on the requirement is not an easy task. Most of time the decision is based on the previous experience and support available for the platform from the community.

cms_0

Here are the major features of TYPO3 that makes a complete Enterprise Level Content Management System.

  • Builtin Multi-Lingual Support and Multi Domain Support under a single backend

    In TYPO3 localization of content elements and pages are very easy to setup. There are more than 50 localisations are available in TYPO3 by default. Also we could create ‘n’ number of multiple domains under a single back-end or installation.

    multi-domain

  • Flexibility in User privilege settings

    We could able to define the rights for back-end users like editor level and superior admin with custom access rights very easily in TYPO3, Flexibility means we could able to lock every page and fields in back-end forms to an Editor.

  • Versioning of Content Elements

    Multiple editors can work on contents in back-end . This can be easily controlled and adjusted thanks to the Workflow function, which also saves all drafts in its history, allowing you to restore older versions easily.

  • Workspace Management

    Contents changed can be reviewed and tested in workspaces. So it’s easy for editors for content proofing and testing the new drafts.

  • Default Caching Mechanism

    Since TYPO3 CMS  4.3, the core is packed with a caching framework that supports a wide variety of storage solutions and options for different caching needs. Which helps to improve performance of the website. The caching framework exists to help speeding up TYPO3 sites, especially heavily loaded ones. It is possible to move all caches to a dedicated cache server with specialized cache systems like the Redis key-value store (a so called NoSQL database).

  • Extensions & Community Support

    For extending the features in TYPO3 there are several extensions/plugins available in TER (TYPO3 Extension Repository ) eg: tt_news,newsletter,metaseo ,realurl etc. These extensions are written in modern framework standards and highly secure. ( Extbase Framework ).

  • LTS Support

    The core of TYPO3 CMS is well maintained and there is a seperate team for security testing in third party extensions available in TER. Always up to date on all the latest industry standards due to its constant maintenance.

  • Seamless Connections to other systems, like CRM or ERP

    These are the major features that makes TYPO3 CMS a complete enterprise level CMS. May be I missed some of the points. If I missed anything please revert your feedback.

Click For Checking Demo of TYPO3 Backend