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
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions config/ezplatform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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']]]);

Expand Down
3 changes: 2 additions & 1 deletion src/ElbformatIconBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class ElbformatIconBundle extends Bundle
{
public function getPath(): string
{
return dirname(__DIR__.'/..');
$path = realpath(__DIR__.'/..');
return false !== $path ? $path : __DIR__.'/..';
}

}
2 changes: 1 addition & 1 deletion src/Form/Type/IconType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
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) }}
Expand Down