From 9387fba6ed6d39ca17f8567c916203595bb9a5ad Mon Sep 17 00:00:00 2001 From: Thorsten Witteler Date: Thu, 19 Oct 2017 18:53:40 +0200 Subject: [PATCH 1/2] nested template --- templates/partials/comments.form.html.twig | 38 +++++++++++ templates/partials/comments.html.twig | 75 ++++++++-------------- 2 files changed, 64 insertions(+), 49 deletions(-) create mode 100644 templates/partials/comments.form.html.twig diff --git a/templates/partials/comments.form.html.twig b/templates/partials/comments.form.html.twig new file mode 100644 index 0000000..dab77dc --- /dev/null +++ b/templates/partials/comments.form.html.twig @@ -0,0 +1,38 @@ +

{{'PLUGIN_COMMENTS.ADD_COMMENT'|t}}

+
+ + {% for field in grav.config.plugins.comments.form.fields %} + {% set value = form.value(field.name) %} + {% if field.evaluateDefault %} + {% set value = evaluate(field.evaluateDefault) %} + {% endif %} + {% if config.plugins.login.enabled and grav.user.authenticated %} + {% if field.name == 'name' %} + + {% elseif field.name == 'email' %} + + {% else %} +
+ {% include "forms/fields/#{field.type}/#{field.type}.html.twig" %} +
+ {% endif %} + {% else %} +
+ {% include "forms/fields/#{field.type}/#{field.type}.html.twig" %} +
+ {% endif %} + {% endfor %} + {% include "forms/fields/formname/formname.html.twig" %} + +
+ {% for button in grav.config.plugins.comments.form.buttons %} + + {% endfor %} +
+ + {{ nonce_field('form', 'form-nonce')|raw }} +
+ +
{{ form.message }}
diff --git a/templates/partials/comments.html.twig b/templates/partials/comments.html.twig index 29d79b9..3eeb423 100644 --- a/templates/partials/comments.html.twig +++ b/templates/partials/comments.html.twig @@ -1,60 +1,37 @@ {% if grav.twig.enable_comments_plugin %} {% set scope = scope ?: 'data.' %} -

{{'PLUGIN_COMMENTS.ADD_COMMENT'|t}}

- -
- - {% for field in grav.config.plugins.comments.form.fields %} - {% set value = form.value(field.name) %} - {% if field.evaluateDefault %} - {% set value = evaluate(field.evaluateDefault) %} - {% endif %} - {% if config.plugins.login.enabled and grav.user.authenticated %} - {% if field.name == 'name' %} - - {% elseif field.name == 'email' %} - - {% else %} -
- {% include "forms/fields/#{field.type}/#{field.type}.html.twig" %} -
- {% endif %} - {% else %} -
- {% include "forms/fields/#{field.type}/#{field.type}.html.twig" %} -
- {% endif %} - {% endfor %} - {% include "forms/fields/formname/formname.html.twig" %} - -
- {% for button in grav.config.plugins.comments.form.buttons %} - - {% endfor %} -
- - {{ nonce_field('form', 'form-nonce')|raw }} -
- -
{{ form.message }}
+ {% include 'partials/comments.form.html.twig' %} {% if grav.twig.comments|length %}

{{'PLUGIN_COMMENTS.COMMENTS'|t}}

- - +
{% for comment in grav.twig.comments|array_reverse %} -
- - +
+
+ + user icon + +
+
+

{{comment.title}}

+
+ Reply +
+
+ {{'PLUGIN_COMMENTS.WRITTEN_ON'|t}} {{comment.date|e}} {{'PLUGIN_COMMENTS.BY'|t}} {{comment.author}} +
+
+ {{comment.text}} +
+ {{nested}} +
+
{% endfor %} -
- {{comment.text}} -
- {{'PLUGIN_COMMENTS.WRITTEN_ON'|t}} {{comment.date|e}} {{'PLUGIN_COMMENTS.BY'|t}} {{comment.author}} -
+ + {% endif %} {% endif %} + + From 1bc97a31e7edf2cad3643c13d8cbe983d4ddf187 Mon Sep 17 00:00:00 2001 From: Thorsten Witteler Date: Thu, 19 Oct 2017 19:40:02 +0200 Subject: [PATCH 2/2] nested template --- templates/partials/comments.html.twig | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/templates/partials/comments.html.twig b/templates/partials/comments.html.twig index 3eeb423..a481604 100644 --- a/templates/partials/comments.html.twig +++ b/templates/partials/comments.html.twig @@ -8,21 +8,19 @@

{{'PLUGIN_COMMENTS.COMMENTS'|t}}

{% for comment in grav.twig.comments|array_reverse %} -
-
+
+ -
-

{{comment.title}}

-
- Reply +
+
+

{{comment.title}}

+ +
{{'PLUGIN_COMMENTS.WRITTEN_ON'|t}} {{comment.date|e}} {{'PLUGIN_COMMENTS.BY'|t}} {{comment.author}}
-
- {{'PLUGIN_COMMENTS.WRITTEN_ON'|t}} {{comment.date|e}} {{'PLUGIN_COMMENTS.BY'|t}} {{comment.author}} -
-
+
{{comment.text}}
{{nested}}