FriendsOfREDAXO / FriendsOfREDAXO/modulsammlung
Slice hijacker MFORM 2025
- Dominant language
- JavaScript
- Stars
- 68
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
**Feature description / Feature Beschreibung**
Ich habe es nicht als PR, weil ich nicht weiß ob hier richtig und wo. Ich habe Thomas' SliceHijacker mal für aktuelle REDAXO Versionen angepasst. Ist das in der Modulsammlung willkommen? Ist eines meiner Lieblingsmodule :)
INPUT
```
getValue(2) == '0') {
// Der Block wird nicht gespeichert
$this->save = false;
// Meldung ausgeben
$this->messages[] = 'Bitte noch einen Slice/Block auswaehlen';
}
?>
*/
function cleanSliceOutput($content) {
// Alle Formularelemente entfernen (input, select, textarea, button, form)
$content = preg_replace('/<(input|select|textarea|button|form)[^>]*>/i', '', $content);
$content = preg_replace('/<\/(select|textarea|button|form)>/i', '', $content);
// required-Attribute entfernen
$content = preg_replace('/\srequired=["\']?required["\']?/i', '', $content);
// Bootstrap-HTML anpassen, um sich in einen Container einzufügen
$content = preg_replace('/
$content = preg_replace('/
return $content;
}
// MFORM-Instanz erstellen
use FriendsOfRedaxo\MForm;
?>
addHtml('
Mit diesem Block können Inhalte anderer Artikel eingebunden werden.
Achtung: Änderungen oder Löschungen im Original wirken sich auf diesen Block aus.
// Artikel auswählen
$mform->addLinkField(1, ['label' => 'Artikel auswählen']);
// Radiobutton: Ganzen Artikel oder Slice wählen
$mform->addRadioField(2, [
'kompletter_artikel' => 'Ganzen Artikel einbinden',
'slice' => 'Einzelnen Slice auswählen'
], ['label' => 'Was soll eingebunden werden?']);
// --- Slice-Auswahl vorbereiten ---
$article_id = "REX_LINK[id=1 output=id]";
$clang = rex_clang::getCurrentId();
if (!empty($article_id) && $article_id > 0) {
$slice = rex_article_slice::getFirstSliceForArticle($article_id, $clang);
if ($slice) {
$mform->addHtml('
while ($slice) {
$slice_id = $slice->getId();
$slice_title = "Slice-ID: $slice_id";
// Einzelnes Radio-Element mit zugehöriger Vorschau
$mform->addRadioField(3, [$slice_id => $slice_title], [
'label' => '',
'class' => 'slice-radio'
]);
// Slice-Vorschau direkt nach dem Radio-Button
$clean_slice_content = cleanSliceOutput($slice->getSlice());
$mform->addHtml('
' . $clean_slice_content . '
$slice = $slice->getNextSlice();
}
$mform->addHtml('
} else {
$mform->addHtml('
}
}
echo $mform->show();
?>
/* Optionales CSS für bessere Darstellung */
.slice-selection {
margin-left: 20px;
}
.slice-radio {
margin-bottom: 10px;
}
.card {
margin-bottom: 20px;
}
```
OUTPUT
```
Eingebundener Inhalt aus:
';
echo $master->getName() . '
} else {
echo '
}
}
if ("REX_VALUE[2]" == "kompletter_artikel") {
// kompletten Artikel einbinden
$art = rex_article::get("REX_LINK[id=1]");
if ($art) {
$article = new rex_article_content($art->getId(), $art->getClang());
echo $article->getArticle(1);
} else {
echo '
}
} else {
// Den Slice/Block laden und anzeigen
$slice = rex_article_slice::getArticleSliceById("REX_VALUE[3]");
if ($slice) {
echo $slice->getSlice();
} else {
echo '
}
}
} else {
// Im Backend kurzen (Fehler-)Text ausgeben
if (rex::isBackend()) {
echo "
Noch keinen Slice/Block ausgewählt.
";}
}
?>
```
Contributor guide
No contributing guide indexed for this repository
Research direction
The proposed module is described entirely in the issue's INPUT and OUTPUT snippets; start by reviewing those snippets against the repository's existing module layout and contribution conventions. Done means deciding whether the SliceHijacker MFORM 2025 adaptation belongs in the collection and, if accepted, adding it in the repository's expected module format.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend, web-dev
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100