How could I insert custom php code on the page?

I need to insert some php code on the page. Twig is not enough to do this.
Is is real to do this?

Inserting custom PHP code in output is a fundamental security risk. Most CMS system’s do not allow this for this very reason.

If you need to have custom PHP for some reason, Grav’s simple plugin system makes this very easy. You can do PHP ‘work’ then set the result as a Twig variable that can be output in a Twig template. Or you can create a Twig filter or function to let you do it dynamically. Or you maybe able to just use Twig’s existing functions to recreate the PHP in Twig syntax.

There’s really nothing that can’t be done with Grav, you just can’t drop in PHP directly into the output.

1 Like