2007/6/15, John DeRosa <[EMAIL PROTECTED]>:
>
> David Larlet wrote:
> > 2007/6/13, John DeRosa <[EMAIL PROTECTED]>:
> >> David Larlet wrote:
> >>> 2006/12/7, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
> >>>> I've been playing with the sitemap stuff and am finding it to be quite
> >>>> slick. I do, however, have some questions about some unusual cases.
> >>>>
> >>>> 1)It works beautifully for listing all the detail pages that make up a
> >>>> list view, but what about the page that takes the list view? In my
> >>>> case, For example, I've got all my guitar pages in there, but not the
> >>>> "guitars" page itself.
> >> An list of objects returned in a sitemap can be for any page on your
> >> site. The object will have an URL associated with it, as well as a
> >> frequency of change and priority, etc. So you can make a list of
> >> objects that are entirely arbitrary, and as long as the URL returned for
> >> each object corresponds to a page on your site (i.e., as long as the URL
> >> returns a page on an HttpGet), everything works as you'd expect.
> >>
> > Is it possible that you just paste an example? Because I've tried with
> > a DummyModel with a get_absolute_url function and it doesn't work...
>
> Ah, that's your problem! You need to define the method location(), not
> get_absolute_url()!
>
> See http://www.djangoproject.com/documentation/0.96/sitemaps/.
>
> An example:
>
> sitemap_classes.py:
> *******************************
> class BrowseTopicSitemap(Sitemap):
> """Browse topic page."""
> changefreq = "weekly"
> priority = 0.9
>
> def items(self):
> """Return a list of objects represent the browse topic page.
>
> The caller doesn't care what type of object these are; all that
> matters
> is that these objects get passed to the location(), lastmod(),
> changefreq() and priority() methods.
> """
> # Return a list containing the most recent topic on the site.
> return
> [Topic.objects.filter(visible=True).order_by("-creation_time")[0]]
>
> def location(self, obj):
> """Return the absolute URL for the browse topic page "object"."""
> return "/browse/"
>
> def lastmod(self, obj):
> """Etc..."""
> <do stuff here...>
> return result
>
>
> def sitemap_dict():
> """Return the current sitemap dict."""
> # Prepare mapping info for the static mapping sections. Each of these
> # sections aren't very large.
> class_list = [("index", IndexSitemap),
> ("browse", BrowseTopicSitemap),
> ("author", AuthorSitemap),
> <more stuff.....>
> ]
>
>
> *************************
>
>
> In the URL config:
> ********************
> urlpatterns += patterns('',
> (r'^sitemap.xml$', "django.contrib.sitemaps.views.index",
> sitemap_dict()),
> (r'^sitemap-(?P<section>.+).xml$',
> "django.contrib.sitemaps.views.sitemap",
> sitemap_dict()),
> )
> ********************
>
>
> John
>
Thanks for your suggestion, I've just done that:
class FakeObject(object):
def __init__(self, url):
self.url = url
class MainSitemap(Sitemap):
priority = 0.8
def items(self):
return [FakeObject('/'),
FakeObject('/archives/'),
...
]
def location(self, obj):
return obj.url
sitemaps = {
'index': MainSitemap(),
...
}
Any thoughts about this implementation?
David
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---