From d0257a1558524158379bc2bf6bef2bc2a8811840 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sun, 12 Dec 2010 22:56:29 +0000 Subject: Fixed #14041 -- Added ability to override the template of the sitemaps views. Thanks, julien. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14883 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/ref/contrib/sitemaps.txt | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/ref/contrib/sitemaps.txt b/docs/ref/contrib/sitemaps.txt index b58b55cab4..a9b1d08f66 100644 --- a/docs/ref/contrib/sitemaps.txt +++ b/docs/ref/contrib/sitemaps.txt @@ -279,8 +279,10 @@ references individual sitemap files, one per each section defined in your Here's what the relevant URLconf lines would look like for the example above:: - (r'^sitemap\.xml$', 'django.contrib.sitemaps.views.index', {'sitemaps': sitemaps}), - (r'^sitemap-(?P
.+)\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}), + urlpatterns = patterns('django.contrib.sitemaps.views', + (r'^sitemap\.xml$', 'index', {'sitemaps': sitemaps}), + (r'^sitemap-(?P
.+)\.xml$', 'sitemap', {'sitemaps': sitemaps}), + ) This will automatically generate a :file:`sitemap.xml` file that references both :file:`sitemap-flatpages.xml` and :file:`sitemap-blog.xml`. The @@ -291,6 +293,26 @@ You should create an index file if one of your sitemaps has more than 50,000 URLs. In this case, Django will automatically paginate the sitemap, and the index will reflect that. +.. versionadded:: 1.3 + +Template customization +====================== + +If you wish to use a different template for each sitemap or sitemap index available on your site, +you may specify it by passing a `template_name` parameter to the `sitemap` and `index` views via +the URLconf:: + + urlpatterns = patterns('django.contrib.sitemaps.views', + (r'^custom-sitemap\.xml$', 'index', { + 'sitemaps': sitemaps, + 'template_name': 'custom_sitemap.html' + }), + (r'^custom-sitemap-(?P
.+)\.xml$', 'sitemap', { + 'sitemaps': sitemaps, + 'template_name': 'custom_sitemap.html' + }), + ) + Pinging Google ============== -- cgit v1.3