diff options
author | Daniel Schadt <kingdread@gmx.de> | 2022-11-28 17:51:00 +0100 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2022-11-28 17:51:00 +0100 |
commit | 49f6b66f34f5019d582baabdd1ae713b163d3a3a (patch) | |
tree | 6900189320c7f6ee660ad1882945c339ca5b47d3 | |
parent | e3dba500584c0975f7d39b84378e7dc698b2a16d (diff) | |
download | fietsboek-49f6b66f34f5019d582baabdd1ae713b163d3a3a.tar.gz fietsboek-49f6b66f34f5019d582baabdd1ae713b163d3a3a.tar.bz2 fietsboek-49f6b66f34f5019d582baabdd1ae713b163d3a3a.zip |
Allow overwriting of the home page
-rw-r--r-- | doc/administration/custom-pages.rst | 21 | ||||
-rw-r--r-- | fietsboek/views/default.py | 13 |
2 files changed, 34 insertions, 0 deletions
diff --git a/doc/administration/custom-pages.rst b/doc/administration/custom-pages.rst index 87d4c7c..db92c49 100644 --- a/doc/administration/custom-pages.rst +++ b/doc/administration/custom-pages.rst @@ -105,6 +105,27 @@ directory will be included: fietsboek.pages = /fietsboek/pages/ +Overwriting the Home Page +------------------------- + +If you set a slug of ``/``, you can overwrite Fietsboek's custom home page: + +.. code:: markdown + + Title: Home + Slug: / + Link-name: home + + Welcome to Fietsboek! + ===================== + +Note that you can use the same ``Locale`` and ``Show-to`` filters for the home +page as you can for other custom pages. If no matching home page is found, +Fietsboek will fall back to the default. + +When defining your own home page, make sure to still include it in the +configuration! + Tips & Tricks ------------- diff --git a/fietsboek/views/default.py b/fietsboek/views/default.py index f61b95c..a36e4c3 100644 --- a/fietsboek/views/default.py +++ b/fietsboek/views/default.py @@ -26,6 +26,19 @@ def home(request): :rtype: pyramid.response.Response """ if not request.identity: + # See if the admin set a custom home page + page = request.pages.find('/', request) + if page is not None: + return render_to_response( + 'fietsboek:templates/static-page.jinja2', + { + 'title': page.title, + 'content': Markup(page.content), + }, + request, + ) + + # Show the default home page locale = request.localizer.locale_name content = util.read_localized_resource(locale, "html/home.html") return { |