From b4cc4f874917c98629e7ed645a7699b97927da71 Mon Sep 17 00:00:00 2001 From: "pmoreno.rodriguez" Date: Thu, 13 Jul 2023 21:50:36 +0200 Subject: [PATCH] twig code optimization --- templates/blog.html.twig | 6 ++-- templates/default.html.twig | 12 +------- templates/error.html.twig | 14 +++++++++ templates/item.html.twig | 2 +- templates/modular.html.twig | 12 +------- templates/offline.html.twig | 16 ++++++++-- templates/partials/base.html.twig | 11 +++++++ templates/partials/blog_item.html.twig | 37 ++++++++++------------- templates/partials/header.html.twig | 5 +-- templates/partials/miniposts.html.twig | 1 + templates/partials/owl-carousel.html.twig | 1 + templates/portfolio.html.twig | 16 +++------- templates/simplesearch_results.html.twig | 2 +- 13 files changed, 70 insertions(+), 65 deletions(-) diff --git a/templates/blog.html.twig b/templates/blog.html.twig index 10c935e..eef52b7 100755 --- a/templates/blog.html.twig +++ b/templates/blog.html.twig @@ -5,8 +5,6 @@ {% set feed_url = base_url %} {% set show_breadcrumbs = header_var('show_breadcrumbs')|defined(true) %} {% set show_pagination = header_var('show_pagination')|defined(true) %} -{% set image = page.media[page.header.primaryImage] ?: page.media.images|first %} -{% set title = page.title|raw %} {# Set page title by taxonomy #} {% if uri.param('category') %} @@ -39,7 +37,7 @@ {% endif %}
-

{{ title }}

+

{{ title }}

{% if listing_title %}

{{ listing_title|raw }}

{% endif %} @@ -52,7 +50,7 @@ {% endif %} {% for child in collection %} - {% include 'partials/blog_item.html.twig' with {'page':child, 'truncate':true} %} + {% include 'partials/blog_item.html.twig' with {'page':child, 'title': child.title|raw, 'subtitle': child.header.subtitle|raw, 'listing': true, 'truncate':true} %} {% endfor %} {% if show_pagination and config.plugins.pagination.enabled and collection.params.pagination %} diff --git a/templates/default.html.twig b/templates/default.html.twig index a51221b..14be3cc 100755 --- a/templates/default.html.twig +++ b/templates/default.html.twig @@ -1,15 +1,5 @@ {% extends 'partials/base.html.twig' %} -{# Define if the primary image and the attributes of width and height are shown #} -{% set show_image = header_var('show_pageimage')|defined(true) %} -{% set image = page.media[page.header.primaryImage] ?: page.media.all|filter((v, k) => k != page.header.primaryImage and (v.type == 'image' or v.type == 'vector'))|first %} -{% set img_width = header_var('image_width')|default(1038) %} -{% set img_height = header_var('image_height')|default(437) %} - -{# Set title and subtitle #} -{% set title = page.title|raw %} -{% set subtitle = page.header.subtitle|raw %} - {% block menu %} {% include 'partials/sidebar_right.html.twig' %} {% endblock %} @@ -18,7 +8,7 @@
-

{{ title }}

+

{{ title }}

{% if subtitle %}

{{ subtitle }}

{% endif %} diff --git a/templates/error.html.twig b/templates/error.html.twig index 6a24692..7fa7ba4 100644 --- a/templates/error.html.twig +++ b/templates/error.html.twig @@ -1,5 +1,7 @@ {% extends 'partials/base.html.twig' %} +{% set sidebar = theme_var('sidebar')|defined(true) %} + {% block menu %} {% include 'partials/sidebar_right.html.twig' %} {% endblock %} @@ -13,4 +15,16 @@
+ + {% if sidebar == false %} + + {% endif %} {% endblock %} + +{% block sidebar %} +{% if sidebar == true %} + {% include 'partials/sidebar_left.html.twig' %} +{% endif %} +{% endblock %} \ No newline at end of file diff --git a/templates/item.html.twig b/templates/item.html.twig index c3e0a6b..67166af 100755 --- a/templates/item.html.twig +++ b/templates/item.html.twig @@ -24,7 +24,7 @@
{% endif %} - {% include 'partials/blog_item.html.twig' with {'truncate':false} %} + {% include 'partials/blog_item.html.twig' with {'listing': false, 'truncate':false} %} {% if show_sidebar == false %}