How can I create my own functions in October CMS?

Viewed 827

The "global" means functions that I can call everywhere on pages and layouts without repeating them on every place where I should use them

1 Answers

You can create your own custom plugin and use registerMarkupTags inside Plugin.php

public function registerMarkupTags()
{
    return [
        'functions' => [
            'currentUrl' => function () {
                return request()->getRequestUri();
            },
            'currentUrlFull' => function () {
                return URL::to(request()->getRequestUri());
            },
            'ip' => function () {
                return Request::ip();
            }
        ]
    ];
}
Related