Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template override fix #6

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix: User default twig namespace to easily override
Hannes Giesenow committed Jul 25, 2024
commit 4508606772a442271a0a315d480ff255536b5ce6
4 changes: 2 additions & 2 deletions config/ezplatform.yaml
Original file line number Diff line number Diff line change
@@ -2,6 +2,6 @@ ezplatform:
system:
default:
field_templates:
- { template: '@ElbformatIconFieldtype/icon_field.html.twig', priority: 0 }
- { template: '@ElbformatIcon/icon_field.html.twig', priority: 0 }
fielddefinition_edit_templates:
- { template: '@ElbformatIconFieldtype/icon_field_type_definition.html.twig', priority: 0 }
- { template: '@ElbformatIcon/icon_field_type_definition.html.twig', priority: 0 }
3 changes: 0 additions & 3 deletions src/DependencyInjection/ElbformatIconExtension.php
Original file line number Diff line number Diff line change
@@ -38,9 +38,6 @@ public function prepend(ContainerBuilder $container): void
$config = Yaml::parse($configFile);
$container->prependExtensionConfig('ezpublish', $config['ezplatform']);

// Register namespace (as this is not done automatically. Maybe the missing "bundle" in path?)
$container->prependExtensionConfig('twig', ['paths' => [__DIR__.'/../../templates' => 'ElbformatIconFieldtype']]);

// Register translations (as this is not done automatically. Maybe the missing "bundle" in path?)
$container->prependExtensionConfig('framework', ['translator' => ['paths' => [__DIR__.'/../../translations']]]);

2 changes: 1 addition & 1 deletion src/Form/Type/IconType.php
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
$iconList = $this->iconSetManager->getSet($iconSet)->getList();
$iconTemplates = [];
foreach($iconList as $icon) {
$iconTemplates[$icon] = $this->twig->render('@ElbformatIconFieldtype/icon.html.twig', ['icon' => $icon,'iconset' => $iconSet]);
$iconTemplates[$icon] = $this->twig->render('@ElbformatIcon/icon.html.twig', ['icon' => $icon,'iconset' => $iconSet]);
}
$builder->add('icon', ChoiceType::class, [
'choices' => $iconList,
2 changes: 1 addition & 1 deletion templates/icon_field.html.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% block icon_field %}
<div class="elbformat-icon">
<div class="icon-container">
{{ include('@ElbformatIconFieldtype/icon.html.twig', {
{{ include('@ElbformatIcon/icon.html.twig', {
icon: field.value.icon,
iconset: fieldSettings.iconset
}, with_context=false) }}