Different views
To display different content in each viewport it is possible to recognize each view through content sections.
<?xml version="1.0" encoding="UTF-8" ?> <Module> <ModulePrefs title="Multiple Views example" summary="" description="" author="" author_email="" thumbnail="" screenshot="" height="380"> <Require feature="opensocial-0.7"/> </ModulePrefs> <Content type="html" view="profile"> <![CDATA[ <p>This shows up at the profile view</p> ]]> </Content> <Content type="html" view="canvas"> <![CDATA[ <p>This shows up at the canvas view</p> ]]> </Content> <Content type="html"> <![CDATA[ <p>This shows up at all the views</p> ]]> </Content> </Module>
Example install (You will have to be in Sandbox mode)
It is also possible to use the default content section and recognize the available views (you need the "views" feature for this):
<?xml version="1.0" encoding="UTF-8" ?> <Module> <ModulePrefs title="Check view" description="" screenshot="" author="" author_email="" author_location="" author_affiliation="" height="200"> <Require feature="opensocial-0.7" /> <Require feature="views" /> </ModulePrefs> <Content type="html"> <![CDATA[ <script type="text/javascript"> function init() { var currentview = gadgets.views.getCurrentView().getName(); var availableviews = gadgets.views.getSupportedViews(); var sContent = ""; if(availableviews[currentview] == availableviews['profile']) { sContent += '<p>This is shown at the profile view</p>'; } else if(availableviews[currentview] == availableviews['canvas']) { sContent += '<p>This is shown at the canvas view</p>'; } sContent += '<p>This is shown at all views</p>'; document.getElementById('content').innerHTML = sContent; } gadgets.util.registerOnLoadHandler(init); </script> <div id="content"></div> ]]> </Content> </Module>
Example install (Make sure you're not in OpenSocial Sandbox mode)
Example file