Skip to content

Using Option API

Blair Jersyer edited this page Jun 21, 2018 · 2 revisions

The option API can be used in two ways, wether it's for the system or for the user. Tendoo ships a frontend API and a Backend API to interact with theses types of Options.

Option Frontend API

This section will treat the option management for the frontend api, for the users and the system.

For the System

Sometime, you might want to update an option of the system without having to refresh entirely a page. It can be made throught an asynchronous request (XHR). Tendoo CMS declare a JavaScript object on each page loaded on the backend called tendooApi. This object host various Frontend object (API) which can be use to interact with the system on the system UI. In order to manipulate the option, here is how it's made :

Creating / updating options

tendooApi.options.save( 'foo', 'bar' ).then( result => {
// result.data consist of a success Object send back by the server.
})

Retreive Options

tendooApi.options.get( 'foo' ).then( result => {
// result.data will return an object with the following shape { value : 'yourvalue' }
})

Delete options

tendooApi.options.delete( 'foo' ).then( result => {
// result.data consist of a success Object send by the server.
})

For the user

The user options is similar to the system option. However, the object which host the implementation of options for the user is different. Note that all options will be saved as a private meta data for the logged user :

Creating / updating options

tendooApi.userOptions.save( 'foo', 'bar' ).then( result => {
// result.data consist of a success Object send back by the server.
})

Retreive Options

tendooApi.userOptions.get( 'foo' ).then( result => {
// result.data will return an object with the following shape { value : 'yourvalue' }
})

Delete options

tendooApi.userOptions.delete( 'foo' ).then( result => {
// result.data consist of a success Object send by the server.
})
  • Hooks

  • Actions

  • Filters

  • API Endpoint

Clone this wiki locally