diff --git a/assets/scripts/admin/content-edit/preview-section.js b/assets/scripts/admin/content-edit/preview-section.js
index 0cbf65b..f9f5d3c 100644
--- a/assets/scripts/admin/content-edit/preview-section.js
+++ b/assets/scripts/admin/content-edit/preview-section.js
@@ -10,6 +10,7 @@ registerFeature('admin_content_edit_preview_section', _init);
*/
function _init() {
cmsEditListener('[data-section-preview-input]', 'change', showSectionPreview);
+ cmsEditListener('[data-section-widget]', 'change', showSectionNote);
}
/**
@@ -24,4 +25,26 @@ function showSectionPreview(inputElement, module, preview/*, form, event*/) {
let sectionPreview = inputElement.options[inputElement.selectedIndex].dataset.sectionPreview;
[...htmlTargetElements].forEach((htmlTargetElement) => htmlTargetElement.innerHTML = sectionPreview === undefined ? '' : sectionPreview);
filterCurrentFilterElements();
+}
+
+/**
+ * Shows a section preview
+ *
+ * The preview target element must have the "data-section-preview-target" attribute
+ * The select option must have the "data-section-preview-input"
+ * Both data attributes must have the same value (as identificator)
+ */
+function showSectionNote(inputElement, module, preview, form/*, event*/) {
+ let htmlTargetElements = form.querySelectorAll("[data-section-note-preview='" + inputElement.id + "']");
+ let sectionNote = inputElement.options[inputElement.selectedIndex].dataset.sectionNotes;
+
+ [...htmlTargetElements].forEach((htmlTargetElement) => {
+ if (sectionNote) {
+ htmlTargetElement.innerHTML = sectionNote;
+ htmlTargetElement.classList.remove('d-none');
+ } else {
+ htmlTargetElement.innerHTML = '';
+ htmlTargetElement.classList.add('d-none');
+ }
+ });
}
\ No newline at end of file
diff --git a/cms/modules/section/form.html.twig b/cms/modules/section/form.html.twig
index e2bb294..98160eb 100644
--- a/cms/modules/section/form.html.twig
+++ b/cms/modules/section/form.html.twig
@@ -7,9 +7,16 @@
{{ sfs_cms_admin_module_accordion_block_end() }}
+{% import '@SfsCms/macros/modules_edit.html.twig' as edit %}
+
{{ sfs_cms_admin_module_accordion_block_start(form, accordion, 'section', true) }}
{{ form_row(form.section, {'attr': attr | merge({'data-section-message-select': ''})}) }}
+
+
+ {{ form.section.vars.section_notes|raw }}
+
+
{{ form_row(form.mode, {'attr': attr | merge({'data-section-mode-message-select': ''})}) }}
true
+
+
diff --git a/src/Form/Admin/Section/SectionCreateForm.php b/src/Form/Admin/Section/SectionCreateForm.php
index ad71b7b..0847a22 100644
--- a/src/Form/Admin/Section/SectionCreateForm.php
+++ b/src/Form/Admin/Section/SectionCreateForm.php
@@ -7,6 +7,7 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
+use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Intl\Locales;
@@ -63,5 +64,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'choices' => array_combine(array_map(fn ($lang) => Locales::getName($lang), $options['locales']), $options['locales']),
'default_value' => [$options['default_locale']],
]);
+
+ $builder->add('notes', TextareaType::class, [
+ 'required' => false,
+ 'help' => 'admin_sections.form.notes.help',
+ ]);
}
}
diff --git a/src/Form/Admin/Section/SectionUpdateForm.php b/src/Form/Admin/Section/SectionUpdateForm.php
index 846cfed..fc57ea4 100644
--- a/src/Form/Admin/Section/SectionUpdateForm.php
+++ b/src/Form/Admin/Section/SectionUpdateForm.php
@@ -7,6 +7,7 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
+use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Intl\Locales;
@@ -65,5 +66,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'constraints' => new Count(['min' => 1]),
'default_value' => [$options['default_locale']],
]);
+
+ $builder->add('notes', TextareaType::class, [
+ 'required' => false,
+ 'help' => 'admin_sections.form.notes.help',
+ ]);
}
}
diff --git a/src/Form/Type/SectionType.php b/src/Form/Type/SectionType.php
index ba53b1b..4c4c00d 100644
--- a/src/Form/Type/SectionType.php
+++ b/src/Form/Type/SectionType.php
@@ -77,6 +77,7 @@ public function configureOptions(OptionsResolver $resolver): void
}
$attr['data-section-preview'] = '';
+ $attr['data-section-notes'] = nl2br($section->getNotes());
foreach ($this->cmsConfig->getSites() as $site) {
foreach ($this->localeHelper->getEnabledLocales() as $locale) {
@@ -95,11 +96,13 @@ public function configureOptions(OptionsResolver $resolver): void
public function finishView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['section_preview'] = '';
+ $view->vars['section_notes'] = '';
/** @var ChoiceView $choice */
foreach ($view->vars['choices'] as $choice) {
if ($view->vars['value'] == $choice->value) {
$view->vars['section_preview'] = $choice->attr['data-section-preview'];
+ $view->vars['section_notes'] = $choice->attr['data-section-notes'];
}
}
}
diff --git a/src/Migrations/Version20251015150528.php b/src/Migrations/Version20251015150528.php
new file mode 100644
index 0000000..689f8fe
--- /dev/null
+++ b/src/Migrations/Version20251015150528.php
@@ -0,0 +1,26 @@
+addSql('ALTER TABLE cms_section ADD notes LONGTEXT DEFAULT NULL');
+ }
+
+ public function down(Schema $schema): void
+ {
+ $this->addSql('ALTER TABLE cms_section DROP notes');
+ }
+}
diff --git a/src/Model/Section.php b/src/Model/Section.php
index 579d022..832f9e4 100644
--- a/src/Model/Section.php
+++ b/src/Model/Section.php
@@ -21,6 +21,8 @@ abstract class Section implements SectionInterface
protected ?array $extraData = null;
+ protected ?string $notes = null;
+
public function __construct()
{
$this->versions = new ArrayCollection();
@@ -58,4 +60,14 @@ public function setExtra(string $key, mixed $value): void
}
$this->extraData[$key] = $value;
}
+
+ public function getNotes(): ?string
+ {
+ return $this->notes;
+ }
+
+ public function setNotes(?string $notes): void
+ {
+ $this->notes = $notes;
+ }
}
diff --git a/src/Model/SectionInterface.php b/src/Model/SectionInterface.php
index 2c711bd..1d84583 100644
--- a/src/Model/SectionInterface.php
+++ b/src/Model/SectionInterface.php
@@ -30,4 +30,8 @@ public function setExtraData(?array $extraData): void;
public function getExtra(string $key, mixed $default = null): mixed;
public function setExtra(string $key, mixed $value): void;
+
+ public function getNotes(): ?string;
+
+ public function setNotes(?string $notes): void;
}
diff --git a/translations/sfs_cms_admin.en.yaml b/translations/sfs_cms_admin.en.yaml
index 7d2dabe..078fa1e 100644
--- a/translations/sfs_cms_admin.en.yaml
+++ b/translations/sfs_cms_admin.en.yaml
@@ -18,6 +18,9 @@ admin_sections:
ttl.label: "Cache time"
defaultLocale.label: "Default language"
locales.label: "Languages"
+ notes:
+ label: "Integration notes"
+ help: "This note is only for internal use, will be displayed when integrating sections in contents. (can contain HTML)"
version_form:
note.label: "Note"
diff --git a/translations/sfs_cms_admin.es.yaml b/translations/sfs_cms_admin.es.yaml
index 80dcce6..600c083 100644
--- a/translations/sfs_cms_admin.es.yaml
+++ b/translations/sfs_cms_admin.es.yaml
@@ -18,6 +18,9 @@ admin_sections:
ttl.label: "Tiempo de cache"
defaultLocale.label: "Idioma por defecto"
locales.label: "Idiomas"
+ notes:
+ label: "Notas de integración"
+ help: "Esta nota es solo para uso interno, se mostrará al integrar secciones en contenidos. (puede contener HTML)"
version_form:
note.label: "Nota"