Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select base template per site

Tags:

wagtail

I am building a setup that will contain a main site and a number of microsites. Each microsite is going to have a separate branding but use the same page types.

Given Wagtail already has a Site object which links to an appropriate Page tree, is there also built in functionality to configure the template loaders to choose an appropriate base.html or will I have to write a custom template loader?

like image 504
Danielle Madeley Avatar asked Dec 08 '22 23:12

Danielle Madeley


1 Answers

Wagtail doesn't have any built-in functionality for this, as it doesn't make any assumptions about how your templates are put together. However, you could probably implement this yourself fairly easily using the wagtail.contrib.settings module, which provides the ability to attach custom properties to individual sites. For example, you could define a TemplateSettings model with a base_template field - your templates can then check this setting and dynamically extend the appropriate template, using something like:

{% load wagtailsettings_tags %}
{% get_settings %}
{% extends settings.my_app.TemplateSettings.base_template %}
like image 118
gasman Avatar answered Jan 09 '23 06:01

gasman