Showing posts with label profile. Show all posts
Showing posts with label profile. Show all posts

Thursday, March 20, 2008

OS:Passing data to apps and navigation

Passing data to your application through requestNavigateTo() †

If you are using the opensocial.requestNavigateTo() calls, you may supply an optional parameter containing data to be passed to the new page.

The following code passes two variables: foo and bar to the canvas surface of the current application:

  function gotoCanvas(params) {
var canvas_surface = new opensocial.Surface("canvas");
opensocial.requestNavigateTo(canvas_surface, params);
};

var my_params = {
foo : 12345,
bar : "Bar value"
};

gotoCanvas(my_params);

In the canvas view, check for these values with the following code:

  var prefs = opensocial.getEnvironment().getParams();
var foo = prefs["foo"];
/* foo contains 12345 */

var bar = prefs["bar"];
/* bar contains "Bar value" */

You should see that after the navigation has taken place, your URL will look similar to:

http://sandbox.orkut.com/Application.aspx?appId=xxxxxx&uid=xxxxxx&appParams=foo%3D12345%26bar%3DBar%20value

This follows the same format as discussed in Passing data to your application through the querystring

Wednesday, February 27, 2008

OS: content navigation

[content type="html" view="profile"]
[!--[CDATA[ [h1]Profile[/h1][br /] ]]--]
[/content]
[content type="html" view="canvas"]
[!--[CDATA[ [h1]Canvas[/h1][br /] ]]--]
[/content]
[content type="html" view="canvas,profile"]
[!--[CDATA[ [h2]This shows up in canvas and profile views[/h2][br /] ]]--]
[/content]
[content type="html"]
[!--[CDATA[ [h1]Default[/h1][br /] [h2]The content in this section only shows up if no other content sections are applicable[/h2][br /] ]]--]
[/content]


Note : replace all "[" with "<" and "]" with ">"