Create a new plugin folder in user/plugins/example, and add those files:
user/plugins/example/example.php
user/plugins/example/example.yaml
Then in your twig, you'll have the users
object available:
{{ dump(users) }}
<?php | |
namespace Grav\Plugin; | |
use \Grav\Common\Plugin; | |
class ExamplePlugin extends Plugin | |
{ | |
public static function getSubscribedEvents() | |
{ | |
return [ | |
'onTwigSiteVariables' => ['onTwigSiteVariables', 0] | |
]; | |
} | |
/** | |
* Make var accessible from twig. | |
*/ | |
public function onTwigSiteVariables() | |
{ | |
if (!$this->active) { | |
return; | |
} | |
$users = .... /* get users data from the user/accounts folder */ | |
$this->grav['twig']->twig_vars['users'] = $users; | |
} | |
} |
enabled: true |