PageFactory (Kirby Plugin)

Auto-Execute

In some, albeit rare situations it may become necessary to invoke custom PHP code.

To achieve this, you can place PHP file(s) in

site/custom/autoexecute/

Any PHP-files in that folder will be loaded and executed (after PageFactory Extensions have been loaded and standard variables have been instantiated).

Thus for instance, the mechanism can be used to load assets, e.g.:

<?php
PgFactoryPageFactoryPageFactory::$pg->addAssets('POPUPS');

Hint:

The most likely case is when you use a macro inside a Twig template. In particular a macro that requires loading of CSS/JS-files.

In that case, requests for loading assets is triggered too late and therefore you need to handle loading manually.