Each extension has 3 different types of settings. App owners manage these settings in Settings pages to customize the functionality of the behaviour of an extension in the app.
Before we dive into settings types, let’s refresh our memory on extension concepts:
extension installation
.shortcut instances
.screen layouts
.Settings pages are web pages written by extension developers, and they appear in Shoutem builder. Their purpose is to enable app owners extension customizations through settings. Check the tutorial on how to create a settings page for more info. Settings pages are exported via the pages
field in extension.json
and can be used on 3 different places which determine settings type.
Extension settings
- Single global settings for the extension installation, placed in settingsPages
in the root of extension.json
Shortcut settings
- Shortcut instance settings, placed in adminPages
in the shortcut objectScreen settings
- Settings of the layout presented by the screen, placed in settingsPage
in the screen object.Each settings can have its default value. The default value is defined in settings
field, which is adjacent to settingsPage(s)
or adminPages
fields, for every settings type.
Applying default settings is determined by settings type:
extension settings
are applied when installing extension into the appshortcut settings
are defined when adding a shortcut (screen) into the app structurescreen settings
are defined when adding a shortcut (screen) into the app structureUpdating the default settings in extension.json
will not update the default settings in that extension part if those were aready applied. For instance, if you already added shortcut instance (created from some shortcut), default settings of that shortcut won’t be updated if you update them in extension.json
and push the new version to Shoutem. However, if you add another shortcut instance, that instance will have the latest default settings from extension.json
.
Settings can be manipulated using the @shoutem/api-sdk package. See Writting settings pages tutorial on how to do that.
Note
The below documentation is outdated and will be updated once
api-sdk
tool is finished. This is in progress.
Extension settings are global settings shared throughout all extension parts within an extension installation.
#file: extension.json
{
"name": "restaurants",
"version": "0.0.1",
"title": "Restaurants",
"description": "List of restaurants",
"platform": "1.0.*",
"settingsPages": [{
"page": "@.General",
"title": "General settings",
}, {
"page": "@.Sounds",
"title": "Sounds"
}],
"settings": {
"website": "www.example.com",
"onRowTapSound": false
},
"pages": [{
"name": "General"
}, {
"name": "Sounds"
}]
}
Settings pages meant for manipulating extension settings can be found in the Extensions
tab for that extension. We call them extension settings pages
.
Properties received to the root extension settings page component are:
extension
: Extension object with fields:
name
: Extension nameversion
: Extension versiontitle
: Extension titlesettings
: Extension global settingsTo set extension settings, use setExtensionSettings
from @shoutem/builder-sdk
. Although extension settings can be manipulated from any settings page, for maximum user experience, do it only in extension settings pages.
Each screen that is connected to the state can access extension settings. They can be found in props
, specifically in props.extension.settings
.
Shortcut settings are settings shared throughout all the screens that were navigated to from the starting screen of the shortcut instance.
#file: extension.json
{
"name": "restaurants",
"version": "0.0.1",
"title": "Restaurants",
"description": "List of restaurants",
"platform": "1.0.*",
"shortcuts": [{
"name": "List",
"title": "Restaurants",
"screen": "@.list",
"adminPages": [{
"page": "shoutem.cms.CmsPage",
"title": "Content",
"parameters": {
"schema": "@.Restaurants"
},
}, {
"page": "@.RestaurantsPage",
"title": "Settings"
}],
"settings": {
"headerTitle": "RESTAURANTS"
}
}],
"dataSchemas": [{
"name": "Restaurants",
"path": "server/schemas/Restaurants.json"
}],
"pages": [{
"name": "RestaurantsPage"
}],
}
Settings pages meant for manipulating shortcut settings can be found next to app structure in the Screens
tab. We call them shortcut settings pages
. Namely, for this example, there should be Content
and Settings
.
Properties received to root shortcut settings page component are:
extension
: Extension object with fields:
name
: Extension nameversion
: Extension versiontitle
: Extension titlesettings
: Extension global settingsshortcut
: Shortcut instance object with fields:
name
: A shortcut’s nametitle
: A shortcut’s titlesettings
: A shortcut instance settingsscreens
: Array of screen objects, each containing:
type
: Type of screen that has layouts (that’s original screen’s name)name
: Name of the layout that will be shownsettings
: Screen settings (shared among all layouts)To set extension settings, use setShortcutSettings
from @shoutem/builder-sdk
. Although shortcut settings can be manipulated from both the shortcut and the screen settings page, for maximum user experience, do it only from the shortcut settings pages.
Each screen that is connected to the state can access shortcut settings. They can be found in props
, specifically in props.shortcut.settings
.
Screen settings are layouts settings that hold information specific for that layout. Check the tutorial for screen layouts to get a better understanding on difference between screen and layouts.
#file: extension.json
{
"name": "restaurants",
"version": "0.0.1",
"title": "Restaurants",
"description": "List of restaurants",
"platform": "1.0.*",
"shortcuts": [{
"name": "List",
"title": "Restaurants",
"screen": "@.list"
}],
"screens": [{
"name": "list",
"title": "List of restaurants",
"settingsPage": {
"title": "Settings",
"page": "@.ListSettings"
},
"settings": {
"groupByStartingLetter": false
}
}, {
"name": "grid",
"extends": "@.list",
"title": "Grid of restaurants",
"settingsPage": {
"title": "Settings",
"page": "@.GridSettings"
},
"settings": {
"gridCellsOfSameHeight": true
}
}]
"pages": [{
"name": "ListSettings"
}, {
"name": "GridSettings"
}],
}
There’s only 1 settings page per screen for manipulating screen settings. It’s located in the Layout
shortcut settings page, under the layout selector, when that screen is selected as the desired layout.
Properties received to root shortcut settings page component are:
extension
: Extension object with fields:
name
: Extension nameversion
: Extension versiontitle
: Extension titlesettings
: Extension global settingsshortcut
: Shortcut instance object with fields:
name
: A shortcut’s nametitle
: A shortcut’s titlesettings
: Shortcut instance settingsscreens
: Array of screen objects, each containing:
type
: Type of screen that has layouts (that’s original screen’s name)name
: Name of the layout that will be shownsettings
: Screen settings (shared among all layouts)screen
: Screen object with fields:
name
: Screen’s name (which is also currently active layout screen)title
: Screen’s titlesettings
: Screen settings (shared among all layouts)To set screen settings in settings page, use setScreenSettings
from @shoutem/builder-sdk
. Screen settings can only be manipulated in screen settings page and using these functions elsewhere will fail. Notice that settings
inside of screen
are in shared namespace, which means that multiple screens which act as different layouts share these settings. If keeping separate namespace per screen is important for you, you can save the settings under key of screen name
.
Each screen connected to the state can access shortcut layouts settings. They can be found in props
, specifically in props.screen.settings
.