Skip to content

Commit

Permalink
Merge pull request #9 from BFoucher/fix/twig2
Browse files Browse the repository at this point in the history
Twig2 support and minor fix
  • Loading branch information
paulandrieux authored Mar 2, 2018
2 parents c99a687 + 820a5a4 commit c873707
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Form/WidgetSitemapType.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('rootPage', null, [
'label' => 'widget_sitemap.form.rootPage.label',
'attr' => ['placeholder' => 'widget_sitemap.form.rootPage.placeholder'],
'placeholder' => 'widget_sitemap.form.rootPage.placeholder',
'required' => true,
])->add('depth', IntegerType::class, [
'label' => 'widget_sitemap.form.depth.label',
'attr' => ['placeholder' => 'widget_sitemap.form.depth.placeholder'],
'placeholder' => 'widget_sitemap.form.depth.placeholder',
'required' => false,
]);
parent::buildForm($builder, $options);
Expand Down
6 changes: 4 additions & 2 deletions Resources/views/show.html.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends 'VictoireCoreBundle:Widget:show.html.twig' %}

{% block content %}
{% import _self as _this %}
{% if rootPage %}
<ul class="depth-0">
<li>
Expand All @@ -10,7 +11,7 @@

{% if rootPageReference.children and depth > 0 or depth is null %}
<ul class="depth-1">
{{ _self.pagesHierarchy(rootPageReference.children, depth, 1) }}
{{ _this.pagesHierarchy(rootPageReference.children, depth, 1) }}
</ul>
{% endif %}
</li>
Expand All @@ -21,14 +22,15 @@
{% endblock content %}

{% macro pagesHierarchy(pageReferences, depth, currentDepth) %}
{% import _self as _this %}
{% for pageReference in pageReferences %}
<li>
<a href="{{ path('victoire_core_page_show', {'url': pageReference.url}) }}" target="_parent">
{{ pageReference.name }}
</a>
{% if pageReference.children and depth > currentDepth or depth is null %}
<ul class="depth-{{ currentDepth + 1 }}">
{{ _self.pagesHierarchy(pageReference.children, depth, currentDepth + 1) }}
{{ _this.pagesHierarchy(pageReference.children, depth, currentDepth + 1) }}
</ul>
{% endif %}
</li>
Expand Down

0 comments on commit c873707

Please sign in to comment.