Building modules for Zikula - It's as simple as that

Modules extend the functionality of your homepage. With Zikula and the ModuleStudio(MOST) creating a module is easy and fast.

For some of my homepages I wanted to create the possibility to automatically convert certain terms into links.

So I planned the module Autolinks with the ModuleStudio, generated it and made it work for me with a little code of my own.

In the following I would like to show you how the model looks like in ModuleStudio and which own code I wrote.

Autolinks - An Entity AutoLink

The AutoLink entity has only 2 fields, namely 'supportedString' for the term to be converted into a link and 'neededLink' for the desired link.

Both fields are logically mandatory fields.

As you can see, I already made an entry for files that should be marked when re-generating the module with the ModuleStudio.

AutoLinks Einstellungen

FilterHooks activated

I have activated the Hook Provider filter in the integration settings. This is crucial for the functionality of the module. It makes it possible to search contents in text fields of other modules and to convert terms into links when hits are made.

AutoLinks Einstellungen 2

Display pattern

The first field 'supportedStrings' is defined as the display pattern.

AutoLinks Einstellungen 3

With these settings I generated the module and created it in Eclipse.

Overwriting in the Hook Provider Filter

In order for the module to do what I want it to do, a little code was needed in the Filter Hook Provider.

In modules generated with the ModuleStudio the relevant Php files are located in the folder 'HookProvider'. The folder itself contains the file 'FilterHooksProvider.php'. The subfolder Base contains the base class 'AbstractFilterHooksProvider.php'.

Php and object-orientation allow the extension and overwriting of code.

The base class can be overwritten with the file in the main folder.

FilterHook 1

I extend the constructor to have the Entity Factory class available. I need this to get all AutoLink entries in the module from the database.

I changed the applyFilter function so that it searches for hits for each entry in the module and rewrites the content accordingly.

2 use statements make sure that I have the required classes, i.e. their properties and methods, available.

FilterHook 2

Services in Sympfony

Zikula uses Symfony completely. This means that Zikula modules use the services from Symfony.

The functionality of the hook provider is one such service.

So that this service can use the Entity Factory class of AutoLinks, it must be made known. This is done in various YAML files located in the 'Resources/config' folder of AutoLinks.

In the file hooks.yml I add the Entity Factory class to the filter_hooks.provider service so that I can use it.

FilterHook 3

Backend in AutoLinks

An entry in the backend of Autolinks then looks like this.

FilterHook 4

All occurrences of '#Banane#' are changed to corresponding links in text fields of modules connected with AutoLinks in the frontend.

AutoLinks is a conceptually simple module, with a quite complex functionality.

The planning, generation with the ModuleStudio and the addition of the code cost me half an hour.

It can be installed and used directly. With the ModuleStudio and a little bit of programming experience, many things can be implemented quickly.

An official release is already available, version 1.0.1 will be released soon.

Project page of AutoLinks:


Similar articles with corresponding issues


  • ModuleStudio
  • Module

Creation and update

Created by michael.ueberschaer on Oct 19, 2018, 5:20 PM
Last update
Updated by michael.ueberschaer on Jan 18, 2019, 10:18 PM
Categories in Blog The latest downloads
  • Zikula 1.5.9
    Read more
  • Zikula 2.0.12
    Read more
  • Bootstrap Standard Theme
    Für Zikula 2.0.11 oder höher - For Zikula 2.0.11 or higher. Dieses Theme ist als...
    Read more
  • Blogging 1.1.0
    Mehrsprachiges Bloggen - Multilingual blogging
    Read more
  • AutoLinks 1.0.1
    Automatische Linkerstellung - Automatic link creation
    Read more