Skip to content

Commit

Permalink
Case studies and blog have same templates but inherited
Browse files Browse the repository at this point in the history
  • Loading branch information
maximehuran committed Aug 22, 2024
1 parent 038ef75 commit a50ec39
Show file tree
Hide file tree
Showing 22 changed files with 46 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/Resources/config/routes/shop/blog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ monsieurbiz_blog_index:
defaults:
_controller: monsieurbiz_blog.controller.article::indexAction
_sylius:
template: "@MonsieurBizSyliusBlogPlugin/Shop/Article/index.html.twig"
template: "@MonsieurBizSyliusBlogPlugin/Shop/Blog/index.html.twig"
grid: monsieurbiz_blog_shop_article_blog
parameters:
type: !php/const MonsieurBiz\SyliusBlogPlugin\Entity\ArticleInterface::BLOG_TYPE
Expand All @@ -15,7 +15,7 @@ monsieurbiz_blog_tag_show:
defaults:
_controller: monsieurbiz_blog.controller.article::indexAction
_sylius:
template: "@MonsieurBizSyliusBlogPlugin/Shop/Article/index.html.twig"
template: "@MonsieurBizSyliusBlogPlugin/Shop/Blog/index.html.twig"
grid: monsieurbiz_blog_shop_tag_article_blog
parameters:
tag: "expr:notFoundOnNull(service('monsieurbiz_blog.repository.tag').findOneBySlug($slug, service('sylius.context.locale').getLocaleCode()))"
Expand All @@ -27,7 +27,7 @@ monsieurbiz_blog_article_show:
defaults:
_controller: monsieurbiz_blog.controller.article::showAction
_sylius:
template: "@MonsieurBizSyliusBlogPlugin/Shop/Article/show.html.twig"
template: "@MonsieurBizSyliusBlogPlugin/Shop/Blog/show.html.twig"
repository:
method: findOnePublishedBySlug
arguments:
Expand Down
6 changes: 3 additions & 3 deletions src/Resources/config/routes/shop/case_study.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ monsieurbiz_case_studies_index:
defaults:
_controller: monsieurbiz_blog.controller.case_study::indexAction
_sylius:
template: "@MonsieurBizSyliusBlogPlugin/Shop/Article/index.html.twig"
template: "@MonsieurBizSyliusBlogPlugin/Shop/CaseStudy/index.html.twig"
grid: monsieurbiz_blog_shop_article_case_study
parameters:
type: !php/const MonsieurBiz\SyliusBlogPlugin\Entity\ArticleInterface::CASE_STUDY_TYPE
Expand All @@ -15,7 +15,7 @@ monsieurbiz_case_studies_tag_show:
defaults:
_controller: monsieurbiz_blog.controller.case_study::indexAction
_sylius:
template: "@MonsieurBizSyliusBlogPlugin/Shop/Article/index.html.twig"
template: "@MonsieurBizSyliusBlogPlugin/Shop/CaseStudy/index.html.twig"
grid: monsieurbiz_blog_shop_tag_article_case_study
parameters:
tag: "expr:notFoundOnNull(service('monsieurbiz_blog.repository.tag').findOneBySlug($slug, service('sylius.context.locale').getLocaleCode()))"
Expand All @@ -27,7 +27,7 @@ monsieurbiz_case_studies_article_show:
defaults:
_controller: monsieurbiz_blog.controller.case_study::showAction
_sylius:
template: "@MonsieurBizSyliusBlogPlugin/Shop/Article/show.html.twig"
template: "@MonsieurBizSyliusBlogPlugin/Shop/CaseStudy/show.html.twig"
repository:
method: findOnePublishedBySlug
arguments:
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/views/Shop/Article/_list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</div>
</div>

{% include '@MonsieurBizSyliusBlogPlugin/Shop/Article/_image.html.twig' %}
{% include '@MonsieurBizSyliusBlogPlugin/Shop/' ~ templateDir ~'/_image.html.twig' %}
</a>
<div class="content">
<a href="{{ path('monsieurbiz_' ~ type ~ '_article_show', { 'slug': article.slug }) }}" class="header">
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/views/Shop/Article/_metadata.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta property="og:type" content="article" />
<meta property="og:url" content="{{ absolute_url(path('monsieurbiz_' ~ type ~ '_article_show', {'slug': article.slug})) }}" />

{% include '@MonsieurBizSyliusBlogPlugin/Shop/Article/Metatags/_image.html.twig' %}
{% include '@MonsieurBizSyliusBlogPlugin/Shop/' ~ templateDir ~'/Metatags/_image.html.twig' %}

{% if article.metaKeywords|default('') is not empty %}
<meta name="keywords" content="{{ article.metaKeywords }}"/>
Expand Down
11 changes: 9 additions & 2 deletions src/Resources/views/Shop/Article/index.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{% extends '@SyliusShop/layout.html.twig' %}

{# Manage folder for templates #}
{% if templateDir is not defined %}
{% set templateDir = 'Article' %}
{% endif %}

{# Manage tag if set #}
{% set tag = configuration.parameters.get('parameters')['tag'] ?? null %}

{# We use plural only for case studies, else is blog #}
Expand All @@ -16,7 +23,7 @@
{% endblock %}

{% block content %}
{% include '@MonsieurBizSyliusBlogPlugin/Shop/Article/_header.html.twig' with {'tag': tag} %}
{% include '@MonsieurBizSyliusBlogPlugin/Shop/' ~ templateDir ~'/_header.html.twig' with {'tag': tag} %}

{% include '@MonsieurBizSyliusBlogPlugin/Shop/Article/_list.html.twig' %}
{% include '@MonsieurBizSyliusBlogPlugin/Shop/' ~ templateDir ~'/_list.html.twig' %}
{% endblock %}
12 changes: 9 additions & 3 deletions src/Resources/views/Shop/Article/show.html.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{% extends '@SyliusShop/layout.html.twig' %}

{# Manage folder for templates #}
{% if templateDir is not defined %}
{% set templateDir = 'Article' %}
{% endif %}

{# Set the `case_study` as article #}
{% set article = resource %}

{# We use plural only for case studies, else is blog #}
Expand All @@ -13,8 +19,8 @@
{% endblock %}

{% block metatags %}
{% include '@MonsieurBizSyliusBlogPlugin/Shop/Article/_metadata.html.twig' %}
{% include '@MonsieurBizSyliusBlogPlugin/Shop/Article/_structured_data.html.twig' %}
{% include '@MonsieurBizSyliusBlogPlugin/Shop/' ~ templateDir ~'/_metadata.html.twig' %}
{% include '@MonsieurBizSyliusBlogPlugin/Shop/' ~ templateDir ~'/_structured_data.html.twig' %}
{% endblock %}

{% block content %}
Expand All @@ -40,7 +46,7 @@
<div class="ui hidden divider"></div>
<div style="width:100%; text-align:center;">
<div class="ui medium image rounded">
{% include '@MonsieurBizSyliusBlogPlugin/Shop/Article/_image.html.twig' with {'filter': 'monsieurbiz_blog_image_large_thumbnail'} %}
{% include '@MonsieurBizSyliusBlogPlugin/Shop/' ~ templateDir ~'/_image.html.twig' with {'filter': 'monsieurbiz_blog_image_large_thumbnail'} %}
</div>
</div>
<div class="ui hidden divider"></div>
Expand Down
1 change: 1 addition & 0 deletions src/Resources/views/Shop/Blog/Metatags/_image.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends '@MonsieurBizSyliusBlogPlugin/Shop/Article/Metatags/_image.html.twig' %}
1 change: 1 addition & 0 deletions src/Resources/views/Shop/Blog/_header.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends '@MonsieurBizSyliusBlogPlugin/Shop/Article/_header.html.twig' %}
1 change: 1 addition & 0 deletions src/Resources/views/Shop/Blog/_image.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends '@MonsieurBizSyliusBlogPlugin/Shop/Article/_image.html.twig' %}
1 change: 1 addition & 0 deletions src/Resources/views/Shop/Blog/_list.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends '@MonsieurBizSyliusBlogPlugin/Shop/Article/_list.html.twig' %}
1 change: 1 addition & 0 deletions src/Resources/views/Shop/Blog/_metadata.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends '@MonsieurBizSyliusBlogPlugin/Shop/Article/_metadata.html.twig' %}
1 change: 1 addition & 0 deletions src/Resources/views/Shop/Blog/_structured_data.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends '@MonsieurBizSyliusBlogPlugin/Shop/Article/_structured_data.html.twig' %}
2 changes: 2 additions & 0 deletions src/Resources/views/Shop/Blog/index.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% set templateDir = 'Blog' %}
{% extends '@MonsieurBizSyliusBlogPlugin/Shop/Article/index.html.twig' %}
2 changes: 2 additions & 0 deletions src/Resources/views/Shop/Blog/show.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% set templateDir = 'Blog' %}
{% extends '@MonsieurBizSyliusBlogPlugin/Shop/Article/show.html.twig' %}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends '@MonsieurBizSyliusBlogPlugin/Shop/Article/Metatags/_image.html.twig' %}
1 change: 1 addition & 0 deletions src/Resources/views/Shop/CaseStudy/_header.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends '@MonsieurBizSyliusBlogPlugin/Shop/Article/_header.html.twig' %}
1 change: 1 addition & 0 deletions src/Resources/views/Shop/CaseStudy/_image.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends '@MonsieurBizSyliusBlogPlugin/Shop/Article/_image.html.twig' %}
1 change: 1 addition & 0 deletions src/Resources/views/Shop/CaseStudy/_list.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends '@MonsieurBizSyliusBlogPlugin/Shop/Article/_list.html.twig' %}
1 change: 1 addition & 0 deletions src/Resources/views/Shop/CaseStudy/_metadata.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends '@MonsieurBizSyliusBlogPlugin/Shop/Article/_metadata.html.twig' %}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends '@MonsieurBizSyliusBlogPlugin/Shop/Article/_structured_data.html.twig' %}
2 changes: 2 additions & 0 deletions src/Resources/views/Shop/CaseStudy/index.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% set templateDir = 'CaseStudy' %}
{% extends '@MonsieurBizSyliusBlogPlugin/Shop/Article/index.html.twig' %}
2 changes: 2 additions & 0 deletions src/Resources/views/Shop/CaseStudy/show.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% set templateDir = 'CaseStudy' %}
{% extends '@MonsieurBizSyliusBlogPlugin/Shop/Article/show.html.twig' %}

0 comments on commit a50ec39

Please sign in to comment.