New answers tagged

3

I would think that you could hook into one of the template render events like: craft\web\View::EVENT_BEFORE_RENDER craft\web\View::EVENT_BEFORE_RENDER_TEMPLATE craft\web\View::EVENT_BEFORE_RENDER_PAGE_TEMPLATE Alternatively, you might want to check out the source code for the KnockKnock plugin, which intercepts page loads to present a custom password ...


3

There is craft\mail\Mailer::EVENT_BEFORE_SEND. You can use the Event Code Generator to find out more


5

You can inject HTML to the end of the body using View Events: use craft\web\View; use yii\base\Event; Event::on( View::class, View::EVENT_END_BODY, function() { echo 'Foobar'; } ); The output of this function will appear wherever the endBody() function is placed in the index.twig. The event will even work if the template doesn't contain this ...


1

You can add permissions using the event EVENT_REGISTER_PERMISSIONS: use craft\events\RegisterUserPermissionsEvent; use craft\services\UserPermissions; use yii\base\Event; Event::on( UserPermissions::class, UserPermissions::EVENT_REGISTER_PERMISSIONS, function(RegisterUserPermissionsEvent $event) { $event->permissions['Permission Group ...


2

To have asset selection and upload in your twig, you can use elementSelectField the code i wrote here is just sample and definitely you need to review, consider security and validation firstly you should have an extra public attribute to keep selected asset on settings model: class Settings extends Model { ..... public $imageId = []; ..... in ...


Top 50 recent answers are included