...
By changing the value of the view
attribute, you can choose where your view renders. For example, on a user's profile:
Section | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
or on the expanded "canvas" view:
Section | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
...
You are not limited to using a single content section for your application. By adding additional Content
sections to your gadget XML spec, you can display entirely different content per view.
Section | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
...
If you have a content section that can be used in multiple views, you can specify multiple comma-separated view names in the view
attribute of the Content
section. The following example renders the same content on the home and profile views:
Section | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
...
The previous gadget will display the following in profile and home views:
<div style="background:#eee; padding: 5px; width: 70%; margin: 10px auto;">
<p><strong>This This text shows up on all views</strong></p>
<p>Elements views
Elements in this content section will be rendered in all views, making it a good place to put JavaScript utility functions.</p> <p><strong>This
This text only shows up on the profile and home views.</strong></p>
</div> In the canvas view, the following is displayed:
<div style="background:#eee; padding: 5px; width: 70%; margin: 10px auto;">
<p><strong>This This text shows up on all views</strong></p>
<p>Elements views
Elements in this content section will be rendered in all views, making it a good place to put JavaScript utility functions.</p> <p><strong>This
This text only shows up on the canvas view.</strong></p>
</div>
Subviews
OpenSocial version 0.9 introduces the concept of subviews. A subview is a user-defined label attached to a view that helps developers create multiple-page applications without resorting to JavaScript. For example, a gadget may have a content section defined for the canvas
view, but also a view called canvas.help
, which would contain help documentation for the gadget. The canvas.help
content section is considered a subview and will not be rendered unless explicitly navigated to using a call to gadgets.view.requestNavigateTo('canvas.help')
.
...