Hallo,
ich möchte als Custom Element - wie das Elementtyp Modul - anbieten, das aber nur bestimmte BE-Module zur Auswahl anbietet.
Wie kann ich das mit RSCE lösen?
Danke für eure Hilfe.
Hallo,
ich möchte als Custom Element - wie das Elementtyp Modul - anbieten, das aber nur bestimmte BE-Module zur Auswahl anbietet.
Wie kann ich das mit RSCE lösen?
Danke für eure Hilfe.
Das müsste man wohl mit einem Callback umsetzen.
Allerdings versteh ich den Nutzen nicht ganz. Weil du gibt dem Benutzer/Benutzergruppe ja die Freigabe/Rechte für Module die er benutzen kann.
Und somit erscheinen in seiner Element-Auswahl auch nur diese Module.
Warum soll er ein RSCE auswählen und darin dann nochmal eine Auswahl treffen?
Könnte der Benutzer doch direkt das gewollte Modul auswählen?
BitteschönPHP-Code:
<?php
use Contao\System;
use Doctrine\DBAL\Connection;
return [
'label' => ['Example', 'Example custom element'],
'types' => ['content'],
'contentCategory' => 'My custom elements',
'standardFields' => ['cssID'],
'wrapper' => ['type' => 'none'],
'fields' => [
'module' => [
'inputType' => 'standardField',
'options_callback' => function() {
$options = [];
// Define allowed module types here
$types = ['navigation', 'customnav', 'breadcrumb'];
/** @var Connection $db */
$db = System::getContainer()->get('database_connection');
$modules = $db->fetchAllAssociative(
"SELECT m.id, m.name, t.name AS theme FROM tl_module m LEFT JOIN tl_theme t ON m.pid=t.id WHERE m.type IN (?) ORDER BY t.name, m.name",
[$types], [Connection::PARAM_STR_ARRAY]
);
foreach ($modules as $module) {
$options[$module['theme']][$module['id']] = $module['name'].' (ID '.$module['id'].')';
}
return $options;
}
],
],
];
Die Zeileeinfach entsprechend ändern.PHP-Code:
// Define allowed module types here
$types = ['navigation', 'customnav', 'breadcrumb'];
Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
Lesezeichen