addBehaviors([ // widget 'initWidgets' => Widgets::initWidgets(...), // blog settings form 'adminBlogPreferencesFormV2' => function (BlogSettingsInterface $blog_settings): void { echo (new Div()) ->class('fieldset') ->items([ (new Text('h4', My::name())) ->id(My::id() . '_params'), (new Para()) ->items([ (new Checkbox(My::id() . 'active', (bool) $blog_settings->get(My::id())->get('active'))) ->value(1), (new Label(__('Enable sessions on public pages'), Label::OUTSIDE_LABEL_AFTER)) ->class('classic') ->for(My::id() . 'active'), ]), (new Para()) ->items([ (new Textarea(My::id() . 'connected', Html::escapeHTML((string) $blog_settings->get(My::id())->get('connected')))) ->rows(6) ->class('maximal') ->label((new Label(__('Text to display on login page when user is connected:'), Label::OL_TF))), ]), (new Para()) ->items([ (new Textarea(My::id() . 'disconnected', Html::escapeHTML((string) $blog_settings->get(My::id())->get('disconnected')))) ->rows(6) ->class('maximal') ->label((new Label(__('Text to display on login page when user is disconnected:'), Label::OL_TF))), ]), ]) ->render(); }, // blog settings update 'adminBeforeBlogSettingsUpdate' => function (BlogSettingsInterface $blog_settings): void { $blog_settings->get(My::id())->put('active', !empty($_POST[My::id() . 'active'])); $blog_settings->get(My::id())->put('connected', $_POST[My::id() . 'connected']); $blog_settings->get(My::id())->put('disconnected', $_POST[My::id() . 'disconnected']); }, // simple menu type 'adminSimpleMenuAddType' => function (ArrayObject $items) { if (My::settings()->get('active')) { $items[My::id()] = new ArrayObject([__('Public login page'), false]); } }, // simple menu select 'adminSimpleMenuBeforeEdit' => function ($type, $select, &$attr) { if ($type == My::id()) { $attr[0] = __('Login'); $attr[1] = __('Sign in to this blog'); $attr[2] = App::blog()->url() . App::url()->getURLFor(My::id()); } }, ]); return true; } }