First birthday and Batflat 1.3.3

First birthday and Batflat 1.3.3

Today is exactly a year since the first version of Batflat came to light! On this occasion we have prepared another update, which introduces some interesting novelties. Check out what's new for you!

Fixed bugs

The admin panel has been optimized for Internet Explorer 11, the Blog module already counts the number of pagination entries correctly, the Navigation has eliminated the error of adding the "active" class to the nested elements, Dashboard doesn't show modules that don't have navigation, Pages module better recognizes no subpages for complex addresses, and QueryBuilder has an improved grouping method.

Observer class

Do you know what are events in JavaScript or jQuery? Something like that can be used in Batflat, that is the class "Event". Events can replace the hook system that extends the functionality of existing solutions. The new class "observes" added events to then execute them in the right place and time. Example:

\Inc\Core\Lib\Event::add('do', function() { echo "Foo!"; });
\Inc\Core\Lib\Event::add('do', function() { echo "Bar!"; });

Widget class

It works almost the same as the observer class, but it differs in that the content returned is also taken into account.

\Inc\Core\Lib\Widget::add('foo', function() { echo "Bar!"; });

Method of termination of module operation

Modules can use the new method called finish(), which only executes after loading any other modules. This method was used to build a useful tool for developers, about which in a moment.

Debugging tool

Debug bar

A completely new module that can be very useful when creating new extensions for Batflat. It is installed by default with the new version of CMS and is activated when the developer mode is enabled in inc/core/defines.php. The Debug Bar lets you know the script's execution time, the number of queries, the contents of global variables and the variables passed by the dump() function.

New QueryBuilder methods

isNull(), isNotNull(), orIsNull(), orIsNotNull() are the names of new methods that are in the database query builder class. They allow you to select rows whose columns are or aren't empty. Example:


Variables as anonymous functions

The template system variable can now be declared an anonymous function. With this solution, the content of the variable will not be unnecessarily generated when it isn't used anywhere. Take the "Contact" module for example. The variable {$contact.form} is usually used only on one subpage, so loading the content on subpages where we do not display the contact form is pointless. By using an anonymous function, we can easily optimize the function of the module, since the function code is executed only after the template variable has been used. Example:

$this->tpl->set('contact', function() {
    return ['form' => $this->_insertForm()];

Syntax highlighting in the editor

The HTML editor already has HTML, CSS, JavaScript, and Markdown syntax highlighting. Highlighting works only in browsers based on Chromium and Firefox.

Searchable select box

Searchable select

When CMS has many subpages, navigation items, or other items included in drop-down lists, manual searching of a particular item can be a bit annoying. To speed up this process, we introduced a search feature within the <select> element. If you want to use the search field in your module view, add a data-use-search="true" attribute to the select box.