List Info

Thread: How do I pass a value in to a gadget?




How do I pass a value in to a gadget?
user name
2006-10-18 18:12:08
johna22gmail.com wrote:
> I want to pass a value into the gadget, what do I need
to put on the
> url of the gadget, and then how do I access it within
the gadget code?

To pass parameters to a gadget you should define some user
preferences
(http://www.google.com/apis/gadgets/guide1.html#Userprefs
).

> I have tried
> htttp://johna11.googlepages.com/gadget.xml?pid=23

Not going to work/does not apply.  The Google servers
generate the HTTP
GET request to your gadget XML file.  They pass all user
preferences
along with the user's language and country code.

> That seems to syntax ok, but how do I get the value
inside the code????

If your gadget has a content type of URL then you can use
the _args
javascript function to grab the parameters that are passed
by Google.
So if you defined a UserPref named fruit then you would
access the
value of that like so:

var currentFruit = _args()["up_fruit"];
if(currentFruit) {
  // currentFruit is a defined value
}

If your gadget is not a URL gadget then you don't have to
mess around
with the _args function.  Just put the literal string
__UP_fruit__ into
your gadget and it will be automagically replaced with the
associated
user preference.

var currentFruit = "__UP_fruit__";
if(currentFruit) {
  // currentFruit is a defined value
}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Google Gadgets API" group.
To post to this group, send email to Google-Homepage-APIgooglegroups.com
To unsubscribe from this group, send email to
Google-Homepage-API-unsubscribegooglegroups.com
For more options, visit this group at ht
tp://groups.google.com/group/Google-Homepage-API
-~----------~----~----~----~------~----~------~--~---

How do I pass a value in to a gadget?
user name
2006-10-18 18:37:55
Hi Justin, thank you for your quick response.

I think I understand what you are saying.

I have an html gadget. I want users to use an 'add to
google' button to
set up the gadget on their homepage. I want to automatically
set their
userid in some way so that i can use it in code within the
gadget.

As I understand it, the only ways I could do this would be

1) To feed a slightly different version of the gadget to
each user (ie
serve my gadget up from a program rather than a file) with
the user id
set inside it

2) Make the user enter their user id into the user prefs
section the
first time they use the gadget

I see that, for example, mcvee has a gadget that shows when
my favorite
shows are on TV, but looking at it, I now think that they
are using
option 1), and that my user id etc are embedded in the
gadget XML.

I guess what i really hoped is that there would be a way to
pass a
parameter in when the gadget is invoked fromthe homepage.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Google Gadgets API" group.
To post to this group, send email to Google-Homepage-APIgooglegroups.com
To unsubscribe from this group, send email to
Google-Homepage-API-unsubscribegooglegroups.com
For more options, visit this group at ht
tp://groups.google.com/group/Google-Homepage-API
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )