Skip to content

Commit

Permalink
Merge pull request #9 from etienne-monsieurbiz/feat/add-link-to-logos
Browse files Browse the repository at this point in the history
Add link in logos blade
  • Loading branch information
Kiwikoti authored Sep 30, 2024
2 parents e312bb7 + e5eb6c3 commit e3b629c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Form/Type/ImageType.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
{
if (!$options['with_link']) {
$builder->remove('link');
$builder->remove('link_type');
}
if (!$options['with_alignment']) {
$builder->remove('align');
Expand Down
3 changes: 3 additions & 0 deletions src/Form/Type/UiElement/LogosUiElementType.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'attr' => [
'class' => 'ui segment secondary collection--flex',
],
'entry_options' => [
'with_link' => true,
],
])
;
}
Expand Down
11 changes: 10 additions & 1 deletion src/Resources/views/Admin/UiElement/logos_ui_element.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ element fields:
- logos
- image
- alt
- link
- link_type
#}

<div>
Expand All @@ -16,7 +18,14 @@ element fields:
<div class="ui grid">
{% for logo in element.logos %}
<div class="four wide column">
<img src="{{ logo.image|imagine_filter('monsieurbiz_sylius_ui_elements_logos') }}" alt="{{ logo.alt|default('') }}" width="180">
{% if logo.link|default('') %}
{% set linkIsBlank = logo.link_type is defined and logo.link_type == constant('MonsieurBiz\\SyliusRichEditorPlugin\\Form\\Type\\LinkTypeType::TYPE_EXTERNAL') %}
<a href="{{ logo.link }}"{% if linkIsBlank %} target="_blank" rel="noopener noreferrer"{% endif %}>
<img src="{{ logo.image|imagine_filter('monsieurbiz_sylius_ui_elements_logos') }}" alt="{{ logo.alt|default('') }}" width="180">
</a>
{% else %}
<img src="{{ logo.image|imagine_filter('monsieurbiz_sylius_ui_elements_logos') }}" alt="{{ logo.alt|default('') }}" width="180">
{% endif %}
</div>
{% endfor %}
</div>
Expand Down
11 changes: 10 additions & 1 deletion src/Resources/views/Shop/UiElement/logos_ui_element.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ element fields:
- logos
- image
- alt
- link
- link_type
#}

<div>
Expand All @@ -16,7 +18,14 @@ element fields:
<div class="ui grid">
{% for logo in element.logos %}
<div class="four wide column">
<img src="{{ logo.image|imagine_filter('monsieurbiz_sylius_ui_elements_logos') }}" alt="{{ logo.alt|default('') }}" width="180">
{% if logo.link|default('') %}
{% set linkIsBlank = logo.link_type is defined and logo.link_type == constant('MonsieurBiz\\SyliusRichEditorPlugin\\Form\\Type\\LinkTypeType::TYPE_EXTERNAL') %}
<a href="{{ logo.link }}"{% if linkIsBlank %} target="_blank" rel="noopener noreferrer"{% endif %}>
<img src="{{ logo.image|imagine_filter('monsieurbiz_sylius_ui_elements_logos') }}" alt="{{ logo.alt|default('') }}" width="180">
</a>
{% else %}
<img src="{{ logo.image|imagine_filter('monsieurbiz_sylius_ui_elements_logos') }}" alt="{{ logo.alt|default('') }}" width="180">
{% endif %}
</div>
{% endfor %}
</div>
Expand Down

0 comments on commit e3b629c

Please sign in to comment.