Basically what I wanted to do is enable only 1 instance of a certain page type (BannerPage) in the site tree.
Overloading the canCreate() function in the BannerPage class works fine but not if you don't reload the backend after creating or deleting a BannerPage. Apparently canCreate() is only checked once when the backend is loaded and without reloading it allows you to create several instances of the page or (after deleting) doesn't re-enable the creation (only after reloading).
To overcome this problem I overrode the onBeforeWrite() function to exit() if an instance of BannerPage exists.
This solves my problem because it is not possible to create more than one instance of BannerPage but has 2 disadvantages:
1. After deleting the only instance of BannerPage no new instance can be created except after reloading the backend
2. No error message is shown to the user when trying to create more BannerPages (it simply doesn't work no matter how often you click) and this might be a little confusing (for him/her)
Anyone has a better solution for this?