SetGetPlugin<-- Contributions to this plugin are appreciated. Please update the plugin page at http://twiki.org/cgi-bin/view/Plugins/SetGetPlugin | |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||
Page contents
Set and get variables and JSON objects in topics, optionally persistently across topic views
Introduction | |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < | Use %SET{}% to store arbitrary text in a named variable, and reuse it with %GET{}% later on within the topic or an included topics. By default, variables live only during topic rendering time, e.g. they do not persist between topic views. It is also possible to remember the variables between topic views, however they are not version controlled like other content in TWiki. | ||||||||||||||||||||||||||||||
> > | Use %SET{}% to store a JSON object or arbitrary text in a named variable, and reuse it with %GET{}% later on within the topic or an included topic. By default, variables live only during topic rendering time, e.g. they do not persist between topic views. It is also possible to make variables persist, e.g. to remember them between topic views. | ||||||||||||||||||||||||||||||
%SET{}% and %GET{}% can be nested inside other TWiki variables and get handled as expected, e.g. inside out, and left to right. | |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < | Alternatives to this plugin are: | ||||||||||||||||||||||||||||||
> > | Alternatives to this plugin: | ||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||
Syntax RulesSET{"name" value="..."} -- set a variable
| |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < | ![]()
| ||||||||||||||||||||||||||||||
> > | ![]()
| ||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||
GET{"name"} -- get a variable
SETGETDUMP{...} -- dump variables
| |||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||
> > |
JSON ObjectsJSON![]()
![]() SET a JSON ObjectThe syntax to set a JSON object is%SET{ name = object }% or %SET{ name.path = object }% .
ERROR:
An optional remember="1" or store="some_name" parameter can be added. Use one or the other, not both. If specified, the JSON object will be stored persistently so that it can be used later in any TWiki topic. The remember="1" option stores the JSON object in the default store; with store="..." you can specify a store name to save the JSON object.
GET a JSON ObjectThe syntax to get a JSON object is%GET{ name }% to get the full object, or %GET{ name.path }% to get a sub-part of the object using a JSON path.
JSON ExamplesExample to set, modify and get a JSON object:
[*] wildcard:
| ||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < | Examples | ||||||||||||||||||||||||||||||
> > | SET/GET Examples | ||||||||||||||||||||||||||||||
Set several timesA variable can be set and used several times.
Search and save resultA SEARCH result can be assigned to a variable for later use. This can be useful for performance reasons if you need the result multiple times. The result can also be post-processed, such as with a$LISTMAP() of the SpreadSheetPlugin.
Last topic view | |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < | In a topic, set a variable with the remember flag set that stores the current time. Add also a GET before the SET, it will show the time the topic has last been viewed. | ||||||||||||||||||||||||||||||
> > | In a topic, set a variable to save the current using the remember flag. Add also a GET before the SET, it will show the time the topic has last been viewed. | ||||||||||||||||||||||||||||||
Remember my moodThis example shows how you can remember the mood of users. The form shows a picklist to select a mood. The mood is stored persistently per user, and shown.
REST InterfaceVariables can also be set and retrieved by invoking a REST (REpresentational State Transfer) request on the TWiki server using the rest script. To persistently remember the state of interactive browser-based JavaScript applications, you can set and get variables using this REST interface via Ajax calls. The rest script requires authentication, e.g. the user agent is prompted to authenticate if needed.rest/SetGetPlugin/set -- set a variableTo set a variable call%SCRIPTURL{rest}%/SetGetPlugin/set . It accepts the following URL parameters:
| |||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||
Example:
http://master-wiki.cloudapp.net/do/rest/SetGetPlugin/set?name=rest-test;value=This+is+REST;remember=1 rest/SetGetPlugin/get -- get a variableTo get a variable call%SCRIPTURL{rest}%/SetGetPlugin/get . It accepts the following URL parameters:
| |||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||
Example:
http://master-wiki.cloudapp.net/do/rest/SetGetPlugin/get?name=rest-test;default=rest-test+variable+not+found | |||||||||||||||||||||||||||||||
Deleted: | |||||||||||||||||||||||||||||||
< < | Plugin Settings<--/twistyPlugin twikiMakeVisibleInline-->
Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>% , i.e. %NEWPLUGIN_SHORTDESCRIPTION%
<--/twistyPlugin--> | ||||||||||||||||||||||||||||||
Plugin Installation InstructionsThis plugin is pre-installed. TWiki administrators can upgrade the plugin as needed on the TWiki server. | |||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||
<--/twistyPlugin twikiMakeVisibleInline-->
| |||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||
<--/twistyPlugin--> Plugin Info | |||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||
<--/twistyPlugin twikiMakeVisibleInline--> | |||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||
<--/twistyPlugin-->
| |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < | Related Topics: VarSET, VarGET, TWikiPlugins, DeveloperDocumentationCategory, AdminDocumentationCategory, TWikiPreferences, SpreadSheetPlugin | ||||||||||||||||||||||||||||||
> > | Related Topics: VarSET, VarGET, VarSETGETDUMP, TWikiPlugins, DeveloperDocumentationCategory, AdminDocumentationCategory, TWikiPreferences, SpreadSheetPlugin | ||||||||||||||||||||||||||||||
SetGetPlugin<-- Contributions to this plugin are appreciated. Please update the plugin page at http://twiki.org/cgi-bin/view/Plugins/SetGetPlugin IntroductionUse%SET{}% to store arbitrary text in a named variable, and reuse it with %GET{}% later on within the topic or an included topics. By default, variables live only during topic rendering time, e.g. they do not persist between topic views. It is also possible to remember the variables between topic views, however they are not version controlled like other content in TWiki.
%SET{}% and %GET{}% can be nested inside other TWiki variables and get handled as expected, e.g. inside out, and left to right.
Alternatives to this plugin are:
Syntax RulesSET{"name" value="..."} -- set a variable
![]()
GET{"name"} -- get a variable
SETGETDUMP{...} -- dump variables
ExamplesSet several timesA variable can be set and used several times.
Search and save resultA SEARCH result can be assigned to a variable for later use. This can be useful for performance reasons if you need the result multiple times. The result can also be post-processed, such as with a$LISTMAP() of the SpreadSheetPlugin.
Last topic viewIn a topic, set a variable with the remember flag set that stores the current time. Add also a GET before the SET, it will show the time the topic has last been viewed.
Remember my moodThis example shows how you can remember the mood of users. The form shows a picklist to select a mood. The mood is stored persistently per user, and shown.
REST InterfaceVariables can also be set and retrieved by invoking a REST (REpresentational State Transfer) request on the TWiki server using the rest script. To persistently remember the state of interactive browser-based JavaScript applications, you can set and get variables using this REST interface via Ajax calls. The rest script requires authentication, e.g. the user agent is prompted to authenticate if needed.rest/SetGetPlugin/set -- set a variableTo set a variable call%SCRIPTURL{rest}%/SetGetPlugin/set . It accepts the following URL parameters:
http://master-wiki.cloudapp.net/do/rest/SetGetPlugin/set?name=rest-test;value=This+is+REST;remember=1 rest/SetGetPlugin/get -- get a variableTo get a variable call%SCRIPTURL{rest}%/SetGetPlugin/get . It accepts the following URL parameters:
http://master-wiki.cloudapp.net/do/rest/SetGetPlugin/get?name=rest-test;default=rest-test+variable+not+found Plugin Settings | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | <--/twistyPlugin twikiMakeVisibleInline--> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>% , i.e. %NEWPLUGIN_SHORTDESCRIPTION%
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | <--/twistyPlugin--> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Plugin Installation Instructions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < | Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | This plugin is pre-installed. TWiki administrators can upgrade the plugin as needed on the TWiki server. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | <--/twistyPlugin twikiMakeVisibleInline--> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | <--/twistyPlugin--> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Plugin Info | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | mode="div"
showlink="Show Change History http://master-wiki.cloudapp.net/twiki/pub/TWiki/TWikiDocGraphics/toggleopen.gif"
hidelink="Hide Change History ![]()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > | </> <--/twistyPlugin--> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
SetGetPlugin<-- Contributions to this plugin are appreciated. Please update the plugin page at http://twiki.org/cgi-bin/view/Plugins/SetGetPlugin IntroductionUse%SET{}% to store arbitrary text in a named variable, and reuse it with %GET{}% later on within the topic or an included topics. By default, variables live only during topic rendering time, e.g. they do not persist between topic views. It is also possible to remember the variables between topic views, however they are not version controlled like other content in TWiki.
%SET{}% and %GET{}% can be nested inside other TWiki variables and get handled as expected, e.g. inside out, and left to right.
Alternatives to this plugin are:
Syntax RulesSET{"name" value="..."} -- set a variable
![]()
GET{"name"} -- get a variable
SETGETDUMP{...} -- dump variables
ExamplesSet several timesA variable can be set and used several times.
Search and save resultA SEARCH result can be assigned to a variable for later use. This can be useful for performance reasons if you need the result multiple times. The result can also be post-processed, such as with a$LISTMAP() of the SpreadSheetPlugin.
Last topic viewIn a topic, set a variable with the remember flag set that stores the current time. Add also a GET before the SET, it will show the time the topic has last been viewed.
Remember my moodThis example shows how you can remember the mood of users. The form shows a picklist to select a mood. The mood is stored persistently per user, and shown.
REST InterfaceVariables can also be set and retrieved by invoking a REST (REpresentational State Transfer) request on the TWiki server using the rest script. To persistently remember the state of interactive browser-based JavaScript applications, you can set and get variables using this REST interface via Ajax calls. The rest script requires authentication, e.g. the user agent is prompted to authenticate if needed.rest/SetGetPlugin/set -- set a variableTo set a variable call%SCRIPTURL{rest}%/SetGetPlugin/set . It accepts the following URL parameters:
http://master-wiki.cloudapp.net/do/rest/SetGetPlugin/set?name=rest-test;value=This+is+REST;remember=1 rest/SetGetPlugin/get -- get a variableTo get a variable call%SCRIPTURL{rest}%/SetGetPlugin/get . It accepts the following URL parameters:
http://master-wiki.cloudapp.net/do/rest/SetGetPlugin/get?name=rest-test;default=rest-test+variable+not+found Plugin SettingsPlugin settings are stored as preferences variables. To reference a plugin setting write%<plugin>_<setting>% , i.e. %NEWPLUGIN_SHORTDESCRIPTION%
Plugin Installation InstructionsNote: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server.
Plugin Info
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
SetGetPlugin<-- Contributions to this plugin are appreciated. Please update the plugin page at http://twiki.org/cgi-bin/view/Plugins/SetGetPlugin IntroductionUse%SET{}% to store arbitrary text in a named variable, and reuse it with %GET{}% later on within the topic or an included topics. By default, variables live only during topic rendering time, e.g. they do not persist between topic views. It is also possible to remember the variables between topic views, however they are not version controlled like other content in TWiki.
%SET{}% and %GET{}% can be nested inside other TWiki variables and get handled as expected, e.g. inside out, and left to right.
Alternatives to this plugin are:
Syntax RulesSET{"name" value="..."} -- set a variable
![]()
GET{"name"} -- get a variable
SETGETDUMP{...} -- dump variables
ExamplesSet several timesA variable can be set and used several times.
Search and save resultA SEARCH result can be assigned to a variable for later use. This can be useful for performance reasons if you need the result multiple times. The result can also be post-processed, such as with a$LISTMAP() of the SpreadSheetPlugin.
Last topic viewIn a topic, set a variable with the remember flag set that stores the current time. Add also a GET before the SET, it will show the time the topic has last been viewed.
Remember my moodThis example shows how you can remember the mood of users. The form shows a picklist to select a mood. The mood is stored persistently per user, and shown.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
REST InterfaceVariables can also be set and retrieved by invoking a REST (REpresentational State Transfer) request on the TWiki server using the rest script. To persistently remember the state of interactive browser-based JavaScript applications, you can set and get variables using this REST interface via Ajax calls. The rest script requires authentication, e.g. the user agent is prompted to authenticate if needed.rest/SetGetPlugin/set -- set a variableTo set a variable call%SCRIPTURL{rest}%/SetGetPlugin/set . It accepts the following URL parameters:
http://master-wiki.cloudapp.net/do/rest/SetGetPlugin/set?name=rest-test;value=This+is+REST;remember=1 rest/SetGetPlugin/get -- get a variableTo get a variable call%SCRIPTURL{rest}%/SetGetPlugin/get . It accepts the following URL parameters:
http://master-wiki.cloudapp.net/do/rest/SetGetPlugin/get?name=rest-test;default=rest-test+variable+not+found | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Plugin SettingsPlugin settings are stored as preferences variables. To reference a plugin setting write%<plugin>_<setting>% , i.e. %NEWPLUGIN_SHORTDESCRIPTION%
Plugin Installation InstructionsNote: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Plugin Info
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< < |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Added: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
> > |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
SetGetPlugin<-- Contributions to this plugin are appreciated. Please update the plugin page at http://twiki.org/cgi-bin/view/Plugins/SetGetPlugin IntroductionUse%SET{}% to store arbitrary text in a named variable, and reuse it with %GET{}% later on within the topic or an included topics. By default, variables live only during topic rendering time, e.g. they do not persist between topic views. It is also possible to remember the variables between topic views, however they are not version controlled like other content in TWiki.
%SET{}% and %GET{}% can be nested inside other TWiki variables and get handled as expected, e.g. inside out, and left to right.
Alternatives to this plugin are:
Syntax RulesSET{"name" value="..."} -- set a variable
![]()
| |||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||
GET{"name"} -- get a variable
| |||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||
> > |
SETGETDUMP{...} -- dump variables
| ||||||||||||||||||||||||
ExamplesSet several timesA variable can be set and used several times.
Search and save resultA SEARCH result can be assigned to a variable for later use. This can be useful for performance reasons if you need the result multiple times. The result can also be post-processed, such as with a$LISTMAP() of the SpreadSheetPlugin.
Last topic viewIn a topic, set a variable with the remember flag set that stores the current time. Add also a GET before the SET, it will show the time the topic has last been viewed.
Remember my moodThis example shows how you can remember the mood of users. The form shows a picklist to select a mood. The mood is stored persistently per user, and shown.
Plugin SettingsPlugin settings are stored as preferences variables. To reference a plugin setting write%<plugin>_<setting>% , i.e. %NEWPLUGIN_SHORTDESCRIPTION%
Plugin Installation InstructionsNote: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server.
| |||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||
Plugin Info
| |||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||
| |||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||
|
SetGetPlugin<-- Contributions to this plugin are appreciated. Please update the plugin page at http://twiki.org/cgi-bin/view/Plugins/SetGetPlugin IntroductionUse%SET{}% to store arbitrary text in a named variable, and reuse it with %GET{}% later on within the topic or an included topics. By default, variables live only during topic rendering time, e.g. they do not persist between topic views. It is also possible to remember the variables between topic views, however they are not version controlled like other content in TWiki.
%SET{}% and %GET{}% can be nested inside other TWiki variables and get handled as expected, e.g. inside out, and left to right.
Alternatives to this plugin are:
Syntax RulesSET{"name" value="..."} -- set a variable
![]()
GET{"name"} -- get a variable
ExamplesSet several timesA variable can be set and used several times.
Search and save resultA SEARCH result can be assigned to a variable for later use. This can be useful for performance reasons if you need the result multiple times. The result can also be post-processed, such as with a$LISTMAP() of the SpreadSheetPlugin.
Last topic viewIn a topic, set a variable with the remember flag set that stores the current time. Add also a GET before the SET, it will show the time the topic has last been viewed.
Remember my moodThis example shows how you can remember the mood of users. The form shows a picklist to select a mood. The mood is stored persistently per user, and shown.
Plugin SettingsPlugin settings are stored as preferences variables. To reference a plugin setting write%<plugin>_<setting>% , i.e. %NEWPLUGIN_SHORTDESCRIPTION%
Plugin Installation InstructionsNote: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server.
Plugin Info
|