cms
cms copied to clipboard
Allow actionButton to be set as a template variable
Description
Allows element index creation in a controller without the need for a template.
Example:
public function actionIndex(): Response
{
return $this
->renderTemplate('_layouts/elementindex', [
'elementType' => Organisation::class,
'title' => Craft::t('_kraftwerk', 'Organisations'),
'selectedSubnavItem' => 'organisations',
'crumbs' => [
[
'label' => Craft::t('_kraftwerk', 'Kraftwerk'),
'url' => '_kraftwerk',
],
[
'label' => Craft::t('_kraftwerk', 'Organisations'),
'url' => '_kraftwerk/organisations',
]
],
'actionButton' => Html::tag(
'a',
Craft::t('_kraftwerk', 'New Organisation'),
[
'href' => UrlHelper::actionUrl('elements/create', [
'elementType' => Organisation::class,
]),
'class' => 'btn submit add icon',
'data-icon' => 'plus',
]),
]);
}