Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

By changing the value of the view attribute, you can choose where your view renders. For example, on a user's profile:

Section
Column

Image RemovedImage Added

Column
Code Block
xml
xml
<Content type="html" view="profile">
  <![CDATA[
    This content section will render on a user's profile.
  ]]>
</Content>

or on the expanded "canvas" view:

Section
Column

Image RemovedImage Added

Column
Code Block
xml
xml
<Content type="html" view="canvas">
  <![CDATA[
    This content section will render on a larger canvas view.
  ]]>
</Content>

Here is a list of common views supported by containers. Note that the list of the supported containers is not complete. You should consult each container's wiki page /wiki/spaces/a/pages/526883 or developer documentation to determine what is available:

...

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
Column

Image RemovedImage Added
Image Removed Image Added

Column
Code Block
xml
xml
<?xml version="1.0" encoding="UTF-8"?>
<Module>
  <ModulePrefs title="Multiple content sections" author="sample.testington@example.com">
    <Require feature="views" />
  </ModulePrefs>
  <Content type="html" view="profile">
    <![CDATA[
      This content section will render on a smaller profile view.
    ]]>
  </Content>
  <Content type="html" view="canvas">
    <![CDATA[
      This content section will render on a larger canvas view.
    ]]>
  </Content>
</Module>

...

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
Column

Image RemovedImage Added
Image Removed Image Added

Column
Code Block
xml
xml
<?xml version="1.0" encoding="UTF-8"?>
<Module>
  <ModulePrefs title="Multiple views" author="sample.testington@example.com">
    <Require feature="views" />
  </ModulePrefs>
  <Content type="html" view="profile, home">
    <![CDATA[
      This content section will render on both the profile and home views.
    ]]>
  </Content>
</Module>

...

The previous gadget will display the following in profile and home views:

Panel
borderStylesolid

This text shows up on all views

Elements in this content section will be rendered in all views, making it a good place to put JavaScript utility functions.

This text only shows up on the profile and home views.

In the canvas view, the following is displayed:

Panel
borderStylesolid

This text shows up on all views

Elements in this content section will be rendered in all views, making it a good place to put JavaScript utility functions.

This text only shows up on the canvas view.

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').

...