kopia lustrzana https://github.com/wagtail/bakerydemo
Snippet and template tag for footer text
rodzic
35dc25f6d7
commit
b0db0bba66
|
@ -0,0 +1,23 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.5 on 2017-02-10 13:38
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import wagtail.wagtailcore.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('base', '0002_auto_20170210_1217'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='FooterText',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('body', wagtail.wagtailcore.fields.RichTextField()),
|
||||
],
|
||||
),
|
||||
]
|
|
@ -55,6 +55,21 @@ class People(ClusterableModel):
|
|||
verbose_name_plural = 'People'
|
||||
|
||||
|
||||
@register_snippet
|
||||
class FooterText(models.Model):
|
||||
body = RichTextField()
|
||||
|
||||
panels = [
|
||||
FieldPanel('body'),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return "Footer text"
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = 'Footer Text'
|
||||
|
||||
|
||||
class AboutLocationRelationship(Orderable, models.Model):
|
||||
"""
|
||||
This defines the relationship between the `LocationPage` within the `locations`
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from django import template
|
||||
from django.template import Template
|
||||
from django.utils.http import urlencode
|
||||
from wagtail.wagtailcore.models import Page
|
||||
from bakerydemo.base.models import FooterText
|
||||
|
||||
|
||||
register = template.Library()
|
||||
# https://docs.djangoproject.com/en/1.9/howto/custom-template-tags/
|
||||
|
@ -87,3 +87,12 @@ def breadcrumbs(context):
|
|||
'ancestors': ancestors,
|
||||
'request': context['request'],
|
||||
}
|
||||
|
||||
|
||||
@register.inclusion_tag('base/include/footer.html', takes_context=True)
|
||||
def get_footer_text(context):
|
||||
footer_text = FooterText.objects.first().body
|
||||
|
||||
return {
|
||||
'footer_text': footer_text,
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@
|
|||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="copyright text-muted">Copyright © Your Website 2016</p>
|
||||
<p class="copyright text-muted">{% get_footer_text %}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
{% load wagtailcore_tags %}
|
||||
|
||||
|
||||
{{ footer_text|richtext }}
|
Ładowanie…
Reference in New Issue