Skip to content

Commit

Permalink
Add custom template for contactformulier plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
pi-sigma committed Dec 4, 2024
1 parent c5de28e commit 136cf58
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/open_inwoner/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@

CMS_TEMPLATES = [
("cms/fullwidth.html", "Home page template"),
("cms/basic.html", "Base template for CMS pages"),
]
CMS_PLACEHOLDER_CONF = {
# TODO properly configure this based on actual available plugins
Expand Down
7 changes: 1 addition & 6 deletions src/open_inwoner/openklant/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,11 @@ class ContactFormPlugin(CMSPluginBase):
form = ContactFormConfigForm
name = _("Contact form plugin")
render_template = "pages/contactform/form.html"
# render_template = "cms/contactform/form.html"
cache = False

fieldsets = ((None, {"fields": ("title", "description")}),)

# def get_render_template(self, context, instance, placeholder):
# request = context["request"]
# if request.path == "/contactform/":
# return "pages/contactform/form.html"
# return ""

def render(self, context, instance, placeholder):
config = OpenKlantConfig.get_solo()
context.update(
Expand Down
14 changes: 14 additions & 0 deletions src/open_inwoner/templates/cms/basic.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% extends 'master.html' %}
{% load i18n cms_tags sekizai_tags static %}


{% block extra_head %}
{% page_attribute "meta_description" as meta_description %}
{{ block.super }}
<meta name="description" content="{{ meta_description }}" />
{% endblock extra_head %}

{% block title %}{% page_attribute "title" as title %}{% page_attribute "page_title" as page_title %}{% if page_title %}{{ page_title }}{% else %}{{ title }}{% endif %} - {{ site_name }}{% endblock title %}
{% block content %}
{% placeholder 'content' or %}{% trans "There is no content." %}{% endplaceholder %}
{% endblock content %}
13 changes: 13 additions & 0 deletions src/open_inwoner/templates/cms/contactform/form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% load cms_tags i18n render_tags %}

{% block content %}
{% if has_form_configuration %}
<h1 class="utrecht-heading-1">
{% trans "Contactformulier" %}
</h1>
<p class="utrecht-paragraph">{{ instance.description|ckeditor_content|safe }}</p>
{% include "components/Contact/ContactForm.html" with form_object=form has_form_configuration=has_form_configuration csrf_token=csrf_token only %}
{% else %}
<p class="utrecht-paragraph">{% trans "Contact formulier niet geconfigureerd." %}</p>
{% endif %}
{% endblock content %}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ul class="footer__list">
{% if has_form_configuration %}
<li class="footer__list-item">
{% link text=_("Contact formulier") secondary=True href="contactform" %}
{% link text=_("Contact formulier") secondary=True href="contactforms" %}
</li>
{% endif %}
{% for flatpage in flatpages %}
Expand Down
1 change: 0 additions & 1 deletion src/open_inwoner/templates/cms/fullwidth.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

{% block title %}{% page_attribute "title" as title %}{% page_attribute "page_title" as page_title %}{% if page_title %}{{ page_title }}{% else %}{{ title }}{% endif %} - {{ site_name }}{% endblock title %}


{% block header_image %}
{% if request.user.is_authenticated %}
{% placeholder 'banner_image' %}
Expand Down
4 changes: 2 additions & 2 deletions src/open_inwoner/templates/master.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
</head>

<body hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' class="utrecht-page">

{% if cookiebanner_enabled %}
{# render cookiebanner first #}
<div class="cookie-banner" id="cookie-banner" aria-labelledby="cookie-banner__title" aria-describedby="cookie-banner__text">
Expand All @@ -79,7 +79,7 @@
</div>
</div>
{% endif %}

{% include "components/Header/AccessibilitySkipLink.html" %}

{% if warning_banner_enabled %}
Expand Down
4 changes: 3 additions & 1 deletion src/open_inwoner/templates/pages/contactform/form.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{% load cms_tags i18n render_tags %}

{% block content %}
{% if has_form_configuration %}
<h1 class="utrecht-heading-1">
{% trans "Contactformulier" %}
{% if instance.title %}{{ instance.title }}{% else %}{% trans "Contactformulier" %}{% endif %}
</h1>
<p class="utrecht-paragraph">{{ instance.description|ckeditor_content|safe }}</p>
{% include "components/Contact/ContactForm.html" with form_object=form has_form_configuration=has_form_configuration csrf_token=csrf_token only %}
{% else %}
<p class="utrecht-paragraph">{% trans "Contact formulier niet geconfigureerd." %}</p>
{% endif %}
{% endblock content %}

0 comments on commit 136cf58

Please sign in to comment.