How do I create a dynamic page when the template is in an extension?

I’m trying to make an extension that produces dynamic pages. Everything is working, as long as I keep the template as a file inside source.

But when I move it to the extension I fail. I can’t figure out how to make it findable when the dynamic page is produced (the problem, I think, is that since it is in the extension, it is not read into the sitemap).

I know it should be possible, since this is what the blog extension does with its tags and calendar pages. I have tried finding the place in blog modules source code where this ‘magic’ is performed, but failed.

A solution, or just a pointer to the right part of blog modules source code, would be much appreciated.

You need to add a sitemap manipulator to your extension that creates a Resource for your template (setting the source to a file in your extension).

This isn’t exactly what the blog extension does (it uses templates in the user’s project, not in the extension).