Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(preview): Fix preview template to take theme template into account #75

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions dist/themes/cms-custom-theme/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "monsieurbiz/cms-custom-theme",
"title": "CMS custom theme",
"extra": {
"sylius-theme": {
"title": "CMS custom theme"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% extends '@SyliusShop/layout.html.twig' %}

{% set metaTitle = page.metaTitle ? page.metaTitle : page.title %}

{% block title %}{{ metaTitle }}{% endblock %}

{% block metatags %}
{{ parent() }}
<meta property="og:type" content="page" />
{% if metaTitle is not empty %}
<meta property="og:title" content="{{ metaTitle }}"/>
{% endif %}
{% if page.metaDescription is not empty %}
<meta name="description" property="og:description" content="{{ page.metaDescription }}"/>
{% endif %}
{% if page.metaKeywords is not empty %}
<meta name="keywords" content="{{ page.metaKeywords }}"/>
{% endif %}
{% endblock %}

{% block content %}
<div style="background-color: #f8f9fa; margin-top: 50px; padding: 50px; border-radius: 5px; margin-bottom: 20px;">
<h1 class="ui monster dividing header">{{ page.title }}</h1>
<div>
{{ page.content|monsieurbiz_richeditor_render_field }}
</div>
</div>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{#
UI Element template
type: text
element fields :
content
align
#}
{% set align = element.align is defined and element.align is not empty ? element.align : 'inherit' %}
{% if element is not empty and element.content is not empty %}
<div style="text-align: {{align}};background-color: #dfe0e1; padding: 20px;">
{{ element.content | raw }}
</div>
{% endif %}
2 changes: 2 additions & 0 deletions src/Resources/config/routing/admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ monsieurbiz_cms_page_admin_page_preview:
defaults:
_controller: monsieurbiz_cms_page.controller.page::previewAction
template: '@MonsieurBizSyliusCmsPagePlugin\\Admin\\Page\\preview.html.twig'
_sylius:
section: shop
2 changes: 2 additions & 0 deletions src/Resources/translations/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ monsieurbiz_cms_page:
actions:
create: 'Create a new page'
preview: 'Preview'
banner:
preview: 'Preview'
monsieurbiz_menu:
provider:
page: 'Page'
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/translations/messages.fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ monsieurbiz_cms_page:
actions:
create: 'Créer une nouvelle page'
preview: 'Prévisualiser'
banner:
preview: 'Prévisualisation'
monsieurbiz_menu:
provider:
page: 'Page'
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/translations/messages.pl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ monsieurbiz_cms_page:
actions:
create: 'Utwórz nową stronę'
preview: 'Podgląd'
banner:
preview: 'Podgląd'
monsieurbiz_menu:
provider:
page: 'Strona'
Expand Down
37 changes: 28 additions & 9 deletions src/Resources/views/Admin/Page/preview.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
{% extends '@MonsieurBizSyliusCmsPagePlugin/Shop/preview_layout.html.twig' %}
{# This extends takes account of the potential theme template #}
{% extends '@MonsieurBizSyliusCmsPagePlugin/Shop/Page/show.html.twig' %}

{% block top %}
<div style="
text-transform: uppercase;
line-height: 30px;
z-index: 999;
position:fixed;
top:0;
left:0;
height: 30px;
background-color: red;
width: 100%;
color: white;
font-weight: bold;
padding: 0 30px;
display: flex;
justify-content: space-between;
">
<div>
<a style="color: white;" href="{{ app.request.headers.get('referer') }}">&#x21A9; {{ 'monsieurbiz_cms_page.ui.back_to_admin' | trans }}</a>
</div>
<div>{{ 'monsieurbiz_cms_page.ui.banner.preview' | trans }}</div>
</div>

{{ parent() }}
{% endblock %}

{% block title %}{{ page.metaTitle }}{% endblock %}

Expand All @@ -15,11 +42,3 @@
<meta name="keywords" content="{{ page.metaKeywords }}"/>
{% endif %}
{% endblock %}

{% block content %}
<h1 class="ui monster dividing header">{{ page.title }}</h1>
<div>
{{ page.content|monsieurbiz_richeditor_render_field }}
</div>
{% endblock %}

26 changes: 0 additions & 26 deletions src/Resources/views/Shop/preview_layout.html.twig

This file was deleted.

Loading