Skip to content

Commit

Permalink
Add ability to control the target for a button
Browse files Browse the repository at this point in the history
  • Loading branch information
gabiudrescu committed Aug 22, 2024
1 parent ee199d3 commit 0dc16dc
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/Form/Type/UiElement/ButtonLinkType.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\AlignmentType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType as FormTextType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;

Expand Down Expand Up @@ -67,6 +68,12 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'label' => 'monsieurbiz_richeditor_plugin.ui_element.monsieurbiz.button.field.link',
'constraints' => $constraintsLink,
])
->add('target', ChoiceType::class, [
'choices' => [
'Open in the same frame as it was clicked (this is default)' => '_self',
'Open in a new window or tab' => '_blank',
],
])
->add('align', AlignmentType::class)
;
}
Expand Down
1 change: 1 addition & 0 deletions src/Resources/translations/messages.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ monsieurbiz_richeditor_plugin:
field:
label: 'Label'
link: 'Link'
target: 'Target'
monsieurbiz.youtube:
title: 'Youtube Element'
short_description: 'A Youtube element.'
Expand Down
1 change: 1 addition & 0 deletions src/Resources/translations/messages.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ monsieurbiz_richeditor_plugin:
field:
label: 'Etiqueta'
link: 'Enlace'
target: 'Destino'
monsieurbiz.youtube:
title: 'Elemento de Youtube'
short_description: 'Un elemento de Youtube.'
Expand Down
1 change: 1 addition & 0 deletions src/Resources/translations/messages.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ monsieurbiz_richeditor_plugin:
field:
label: 'Libellé'
link: 'Lien'
target: 'Cible'
monsieurbiz.youtube:
title: 'Lame Youtube'
short_description: 'Une vidéo youtube.'
Expand Down
1 change: 1 addition & 0 deletions src/Resources/translations/messages.hr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ monsieurbiz_richeditor_plugin:
field:
label: 'Natpis na gumbu'
link: 'URL linka'
target: 'Ciljni'
monsieurbiz.youtube:
title: 'YouTube video'
short_description: 'Element s YouTube videom.'
Expand Down
1 change: 1 addition & 0 deletions src/Resources/translations/messages.nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ monsieurbiz_richeditor_plugin:
field:
label: 'Label'
link: 'Link'
target: 'Doelkenmerk'
monsieurbiz.youtube:
title: 'YouTube-video'
short_description: 'Een YouTube-element.'
Expand Down
1 change: 1 addition & 0 deletions src/Resources/translations/messages.pl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ monsieurbiz_richeditor_plugin:
field:
label: 'Etykieta'
link: 'Link'
target: 'Docelowy'
monsieurbiz.youtube:
title: 'Element YouTube'
short_description: 'Element YouTube.'
Expand Down
4 changes: 3 additions & 1 deletion src/Resources/views/Admin/UiElement/button.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
element fields :
label
link
target
align
#}
{% set align = element.align is defined and element.align is not empty ? element.align : 'center' %}
{% set target = element.target is defined and element.target is not empty ? element.target : '_self' %}
<p style="text-align: {{align}};">
<a href="{{ element.link }}" class="ui primary button massive">{{ element.label }}</a>
<a href="{{ element.link }}" target="{{ element.target }}" rel="noopener noreferrer" class="ui primary button massive">{{ element.label }}</a>
</p>

0 comments on commit 0dc16dc

Please sign in to comment.