EventLoader by Iskender TOTOGLU

Event Loader module module allow you to load events from event files

EventLoader Module for ProcessWire CMS/CMF

EventLoader module allow you to load events from a event files.

Requirements


  • ProcessWire 3.0 or newer
  • PHP 7.0 or newer

Installation


Install the module from the modules directory:

Via Composer:

composer require trk/processwire-event-loader

Via git clone:

cd your-processwire-project-folder/
cd site/modules/
git clone https://github.com/trk/EventLoader.git
  • Loading events from site/ready.php file
<?php namespace ProcessWire;

if(!defined("PROCESSWIRE")) die();

EventLoader::load(__DIR__ . '/templates', 'ready.');
  • Event file: site/templates/configs/events/ready.hello-world.php
<?php

namespace ProcessWire;

return [
    // 'run' => true, // Also you can pass run option for this file
    'events' => [
        'Page::private' => [
            'run' => wire()->user->isLoggedin()
            'type' => 'method',
            'fn' => function (HookEvent $e) {
                $e->return = 'This will run, if user logged in';
            }
        ],
        'Page::hello' => [
            'type' => 'method',
            'fn' => function (HookEvent $e) {
                $message = is_string($e->arguments(0)) ? $e->arguments(0) : '';
                $e->return = $message;
            }
        ]
    ]
];
  • Usage
<?php
echo $page->hello('World');

Install and use modules at your own risk. Always have a site and database backup before installing new modules.

Twitter updates

  • New ProcessWire “User Activity” module version released (v5), this post covers what's new— More
    12 August 2022
  • New post: Multi-language field translation export/import — In this post we cover the details of a new module that enables export and import capabilities for multi-language fields in ProcessWire… More
    5 August 2022
  • Weekly update, July 29: Continuing upgrades to ProcessWire’s comments system and FormBuilder, along with a working example—More
    29 July 2022

Latest news

  • ProcessWire Weekly #430
    In the 430th issue of ProcessWire Weekly we're going to check out some brand new third party modules, a new site of the week, and more. Read on!
    Weekly.pw / 7 August 2022
  • Multi-language field translation export/import
    In this post we cover the details of a new module that enables export and import capabilities for multi-language fields in ProcessWire.
    Blog / 5 August 2022
  • Subscribe to weekly ProcessWire news

“I am currently managing a ProcessWire site with 2 million+ pages. It’s admirably fast, and much, much faster than any other CMS we tested.” —Nickie, Web developer