From 9dc080bed82650c2f23403651af0f1d094fa30cd Mon Sep 17 00:00:00 2001 From: pikim Date: Tue, 20 Dec 2022 00:17:26 +0100 Subject: [PATCH] Harmonize and modify twigs --- templates/blog.html.twig | 88 +++++++-------- templates/default.html.twig | 51 +++++---- templates/item.html.twig | 46 ++++---- templates/partials/blog_item.html.twig | 142 ++++++++++++------------- 4 files changed, 157 insertions(+), 170 deletions(-) diff --git a/templates/blog.html.twig b/templates/blog.html.twig index 3c9743a..12fc982 100644 --- a/templates/blog.html.twig +++ b/templates/blog.html.twig @@ -1,49 +1,51 @@ -{% embed 'partials/base.html.twig' %} +{% extends 'partials/base.html.twig' %} - {% set collection = page.collection() %} - {% set base_url = page.url %} - {% set feed_url = base_url %} - {% if page.header.show_breadcrumbs is defined %} +{% set collection = page.collection() %} +{% set base_url = page.url %} +{% set feed_url = base_url %} +{% if page.header.show_breadcrumbs is defined %} {% set show_breadcrumbs = page.header.show_breadcrumbs %} - {% else %} - {% set show_breadcrumbs = true %} - {% endif %} - {% if page.header.show_pagination is defined %} - {% set show_pagination = page.header.show_pagination %} - {% else %} - {% set show_pagination = true %} - {% endif %} +{% else %} + {% set show_breadcrumbs = true %} +{% endif %} +{% if page.header.show_pagination is defined %} + {% set show_pagination = page.header.show_pagination %} +{% else %} + {% set show_pagination = true %} +{% endif %} - {% if base_url == '/' %} +{% if base_url == '/' %} {% set base_url = '' %} +{% endif %} + +{% if base_url == base_url_relative %} + {% set feed_url = base_url~'/'~page.slug %} +{% endif %} + +{% block menu %} + {% include 'partials/sidebar_right.html.twig' %} +{% endblock %} + +{% block content %} + {% if show_breadcrumbs and config.plugins.breadcrumbs.enabled %} + {% include 'partials/breadcrumbs.html.twig' %} + {% endif %} +{# + {% if show_pagination and config.plugins.pagination.enabled and collection.params.pagination %} + {% include 'partials/pagination.html.twig' with {base_url: page.url, pagination: collection.params.pagination} %} + {% endif %} +#} + {% for child in collection %} + {% if child.header.hide is not defined or not child.header.hide %} + {% include 'partials/blog_item.html.twig' with {'page':child, 'truncate':true} %} + {% endif %} + {% endfor %} + + {% if show_pagination and config.plugins.pagination.enabled and collection.params.pagination %} + {% include 'partials/pagination.html.twig' with {base_url: page.url, pagination: collection.params.pagination} %} {% endif %} - {% if base_url == base_url_relative %} - {% set feed_url = base_url~'/'~page.slug %} - {% endif %} - - {% block menu %} - {% include 'partials/sidebar_right.html.twig' %} - {% endblock %} - - {% block content %} - {% if show_breadcrumbs and config.plugins.breadcrumbs.enabled %} - {% include 'partials/breadcrumbs.html.twig' %} - {% endif %} - - {% for child in collection %} - {% include 'partials/blog_item.html.twig' with {'page':child, 'truncate':true} %} - {% endfor %} - - {% if show_pagination and config.plugins.pagination.enabled and collection.params.pagination %} - {% include 'partials/pagination.html.twig' with {base_url: page.url, pagination: collection.params.pagination} %} - {% endif %} - {% endblock %} - - {% block sidebar %} - {% include 'partials/sidebar_left.html.twig' %} - {% endblock %} - -{% endembed %} - - + +{% endblock %} diff --git a/templates/default.html.twig b/templates/default.html.twig index ffdc1a6..ec3ecd3 100644 --- a/templates/default.html.twig +++ b/templates/default.html.twig @@ -1,34 +1,33 @@ {% extends 'partials/base.html.twig' %} +{% if page.header.show_breadcrumbs is defined %} + {% set show_breadcrumbs = page.header.show_breadcrumbs %} +{% else %} + {% set show_breadcrumbs = true %} +{% endif %} + {% block menu %} - {% include 'partials/sidebar_right.html.twig' %} + {% include 'partials/sidebar_right.html.twig' %} {% endblock %} {% block content %} -
-
-
-

{{ page.header.title }}

- {% if page.header.subtitle %} -

{{ page.header.subtitle }}

- {% endif %} -
+ {% if show_breadcrumbs and config.plugins.breadcrumbs.enabled %} + {% include 'partials/breadcrumbs.html.twig' %} + {% endif %} -
- {% if page.header.primaryImage %} - {{ page.media[page.header.primaryImage].cropZoom(1038,437).loading('lazy').html(page.title, page.title, 'image featured')|raw }} - {% else %} - {{ page.media.images|first.cropZoom(1038,437).loading('lazy').html(page.title, page.title, 'image featured')|raw }} - {% endif %} - {{ page.content|raw}} - -
- +
+
+
+

{{ page.header.title }}

+ {% if page.header.subtitle %} +

{{ page.header.subtitle }}

+ {% endif %} +
+
+ {{ page.content|raw }} +
+ + {% endblock %} - - - diff --git a/templates/item.html.twig b/templates/item.html.twig index baa5f01..dbe1a6a 100644 --- a/templates/item.html.twig +++ b/templates/item.html.twig @@ -1,31 +1,23 @@ -{% embed 'partials/base.html.twig' %} - {% set base_url = page.parent.url %} - {% set feed_url = base_url %} - {% set show_breadcrumbs = header_var('show_breadcrumbs', [page, blog]) %} +{% extends 'partials/base.html.twig' %} - {% if base_url == '/' %} - {% set base_url = '' %} +{% if page.header.show_breadcrumbs is defined %} + {% set show_breadcrumbs = page.header.show_breadcrumbs %} +{% else %} + {% set show_breadcrumbs = true %} +{% endif %} + +{% block menu %} + {% include 'partials/sidebar_right.html.twig' %} +{% endblock %} + +{% block content %} + {% if show_breadcrumbs and config.plugins.breadcrumbs.enabled %} + {% include 'partials/breadcrumbs.html.twig' %} {% endif %} - {% if base_url == base_url_relative %} - {% set feed_url = base_url~'/'~page.parent.slug %} - {% endif %} - - {% block menu %} - {% include 'partials/sidebar_right.html.twig' %} - {% endblock %} + {% include 'partials/blog_item.html.twig' with {'truncate':false} %} - {% block content %} - - {% if show_breadcrumbs and config.plugins.breadcrumbs.enabled %} - {% include 'partials/breadcrumbs.html.twig' %} - {% endif %} - - {% include 'partials/blog_item.html.twig' with {'truncate':false} %} - - - {% endblock %} - -{% endembed %} + +{% endblock %} diff --git a/templates/partials/blog_item.html.twig b/templates/partials/blog_item.html.twig index 38dd6e9..5837448 100644 --- a/templates/partials/blog_item.html.twig +++ b/templates/partials/blog_item.html.twig @@ -1,93 +1,87 @@ -
- {% if page.header.author %} - {% set author = page.header.author %} - {% else %} - {% set author = page.header.taxonomy.author[0] %} - {% endif %} - {% if author %} - {% set avatar = author|replace(' ', '-')|lower %} - {% endif %} - -
+
+{% if page.header.author %} + {% set author = page.header.author %} +{% else %} + {% set author = page.header.taxonomy.author[0] %} +{% endif %} +{% if author %} + {% set avatar = author|replace(' ', '-')|lower %} +{% endif %} + +
- {% if page.header.link %} -

- {% if page.header.continue_link is not sameas(false) %} - - {% endif %} - {{ page.title }} -

- {% else %} -

{{ page.title }}

- {% endif %} - {% if page.header.subtitle %} -

{{ page.header.subtitle|raw }}

+ {% if page.header.link %} +

+ {% if page.header.continue_link is not sameas(false) %} + {% endif %} + {{ page.title }} +

+ {% else %} +

{{ page.title }}

+ {% endif %} + {% if page.header.subtitle %} +

{{ page.header.subtitle|raw }}

+ {% endif %}
- - {% if author %} - {{ tag }}{% if page.header.avatarImage %}{{ author }}{% endif %} - {% endif %} + + {% if author %} + {{ tag }}{% if page.header.avatarImage %}{{ author }}{% endif %} + {% endif %}
-
+
- {% if page.header.primaryImage %} - {{ page.media[page.header.primaryImage].cropZoom(1038,437).loading('lazy').html(page.title, page.title, 'image featured')|raw }} - {% else %} - {{ page.media.images|first.cropZoom(1038,437).loading('lazy').html(page.title, page.title, 'image featured')|raw }} - {% endif %} +{% if page.header.primaryImage %} + {{ page.media[page.header.primaryImage].cropZoom(1038,437).loading('lazy').html(page.title, page.title, 'image featured')|raw }} +{% elseif page.media.images %} + {{ page.media.images|first.cropZoom(1038,437).loading('lazy').html(page.title, page.title, 'image featured')|raw }} +{% endif %} - -
- - {% if page.header.continue_link is sameas(false) %} - {{ page.content|raw }} - {% if not truncate %} - {% set show_prev_next = true %} - {% endif %} - {% elseif truncate and page.summary != page.content %} - {{ page.summary|raw }} - {% elseif truncate %} - {{ page.content|truncate(550)|raw }} - {% else %} - {{ page.content|raw }} - {% set show_prev_next = true %} - {% endif %} +{% if page.header.blog_hide_body is not defined or not page.header.blog_hide_body %} +
+ {% if page.header.continue_link is sameas(false) %} + {{ page.content|raw }} + {% if not truncate %} + {% set show_prev_next = true %} + {% endif %} + {% elseif truncate and page.summary != page.content %} + {{ page.summary|raw }} + {% elseif truncate %} + {{ page.content|truncate(550)|raw }} + {% else %} + {{ page.content|raw }} + {% set show_prev_next = true %} + {% endif %} +
+{% endif %} -
- -