Friday, 27 June 2008

Supporting views while keeping compatibility



As we begin to ramp up support for the canvas view in iGoogle, it's important to remember that not all users will get access to the canvas view simultaneously.

If you've upgraded one of your gadgets to use views, you can keep backwards compatibility by keeping your old content section in your XML. Just make sure it appears first in your list of content sections and that it doesn't set a view attribute. Your new content sections with view="home" and view="canvas" can follow in any order.

<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Backwards Compatibility">
</ModulePrefs>
<Content type="html">
<![CDATA[
Users without access to canvas view see this.
]]>
</Content>
<Content type="html" view="home">
<![CDATA[
Users with canvas view see this in the "home" view.
]]>
</Content>
<Content type="html" view="canvas">
<![CDATA[
Users with canvas view see this in the "canvas" view.
]]>
</Content>
</Module>

Once you've set up your gadget in this way, anyone who uses an iGoogle domain that doesn't yet have access to the canvas view can see a working version of your gadget. And those who have been moved to the new interface will see all the hard work you've put into your home and canvas views.

As an added bonus, you can use this technique now to develop gadgets in the developer sandbox that still maintain their old behavior in production. Whenever more users do get access to the canvas view, your gadgets will be ready to go.