nephila / djangocms-page-sitemap

django CMS page extension to handle sitemap customization
BSD 3-Clause "New" or "Revised" License
9 stars 21 forks source link

I'm not sure if it's an issue, or something I'm doing wrong. #49

Closed niz11 closed 4 years ago

niz11 commented 4 years ago

Hi there,

So I start working in a company that uses Django cms. They have three different sitemaps. One using your extensions, and the other two using the Django sitemap. Your extension provides the nice menu tool, so I was trying to convert the other two sitemaps to use your extension. When I'm trying to change one of the Django sitemaps to use the extension, I'm getting two identical sitemaps. The sitemap that originally used the extension. Any idea why? In urls I didn't change anything. And inside the sitemap, I converted it from:

from .models import Post from django.contrib.sitemaps import Sitemap

class PostSitemap(Sitemap): changefreq = "weekly" protocol = "https"

def items(self):
    return Post.objects.filter(is_published=True)

def lastmod(self, obj):
    return max(obj.changed_at.date(), obj.pub_date)

def priority(self, obj):
    return obj.priority

to: from djangocms_page_sitemap.sitemap import ExtendedSitemap

class PostSitemap(ExtendedSitemap): protocol = "https"

Any suggestions?

yakky commented 4 years ago

djangocms-page-sitemap only handles django CMS pages. By replacing def items(self): with the one from ExtendedSitemap you will get a list of cms pages in your sitemap. There is not much code you can reuse, if you have to implement what this application does for cms pages in custom applications.

best pointer I can give you is to include the fields directly in your models (like Post.changefreq etc), adapt your PostSitemap(Sitemap) copy the logic from ExtendedSitemap and implement a toolbar similar to PageSitemapPropertiesMeta(but likely simpler due to the permissions and state check logic in PageSitemapPropertiesMeta)

niz11 commented 4 years ago

Thank you for the quick response and happy new year :)

yakky commented 4 years ago

Happy for being helpful happy new year you too!