omz13 / kirby3-xmlsitemap

kirby3 plugin to generate an xml-based sitemap
59 stars 10 forks source link

Filter missing translations #26

Closed mauricerenck closed 5 years ago

mauricerenck commented 5 years ago

It would be nice to exclude translations of pages which aren't existing (but showing the content of the original language).

Example: I do have two languages enabled, german (default) and english. My podcast is german only, there is no translation. The sitemap lists the german posts, but it also lists urls to the english translation, which is not available. If you would open one of those urls you would see the german content (because it's the default lang).

On my site I do an extra check for that. So if you would open an non-existing translation, you'll get an 404 instead of the german content. But it would be nice, if those urls do not even appear in the sitemap.

In my templates I do the following, maybe this can be used in some way in your plugin, too:

foreach($page->translations() as $translation) { if($kirby->language()->code() == $translation->code() && !$page->translation($translation->code())->exists()) { go($translation->code() . '/error/' . $page->uid()); } }

This causes a 404 if the translation isn't available.

omz13 commented 5 years ago

Not a bad idea. I'll push out an update next week.

illycz commented 5 years ago

This option is not working for me. I'm setting hideuntranslated to true but pages which is translated and the text file for this language exist still missing from sitemap. Any suggestions?

Thanks

illycz commented 5 years ago

I don't know if it's related somehow, but I have same content on my local and dev environment and see different results. 66 results on local and 74 on dev. I also see bad number of images for example article.

Thanks

illycz commented 5 years ago

Solved. Problem with plugin cache and namespace option.