Skip to main content

Custom Portal Block

A Custom Portal Block is a block of your own that appears in the Portal Builder next to the built-in blocks. A portal builder places it on a portal page and, if you offer settings, configures each placement separately.

Use a Portal Block when you want to show your own interface inside a portal. To connect a portal to your backend without an interface, for example to check a registration or load consumption data, use a Portal Extension instead.

Creating a Portal Block​

Add the component in the App Builder (Portal Block), or with the CLI:

epilot app add-component my-widget --type CUSTOM_PORTAL_BLOCK

In the manifest it looks like this:

{
"id": "7b2a…",
"component_type": "CUSTOM_PORTAL_BLOCK",
"name": { "de": "Mein Widget", "en": "My Widget" },
"configuration": {},
"surfaces": {
"portal_block": {
"app_url": "./components/my-widget/dist/index.html",
"supported_surfaces": ["main"]
}
},
"assets": { "zip": "./components/my-widget/dist/" }
}
FieldRequiredDescription
surfaces.portal_block.app_url✓Entry file of your block's interface
surfaces.portal_block.supported_surfaces—Where in a portal the block may be placed, see below. Defaults to ["main"]
surfaces.portal_block.settings—Settings a portal builder can set per placed block, see Block settings
assets.zip✓Directory that is uploaded on deploy

Where a block can be placed​

ValuePlacement
mainIn the main content of a portal page
footer_inlineIn the footer, as part of the page flow
footer_left_absoluteFixed to the bottom left of the page
footer_right_absoluteFixed to the bottom right of the page

Block settings​

Settings let a portal builder configure each placed instance of your block, for example a headline or which journey a button opens. The Portal Builder renders a form from the fields you declare, stores the values on the block, and the portal passes them to your block as config.settings.

"settings": {
"version": 1,
"fields": [
{ "key": "headline", "type": "translated_text", "label": { "de": "Überschrift", "en": "Headline" } },
{ "key": "showPrices", "type": "boolean", "label": { "de": "Preise anzeigen", "en": "Show prices" }, "default": true },
{ "key": "journey", "type": "journey", "label": { "de": "Journey", "en": "Journey" }, "required": true }
]
}

A block can declare up to 30 fields. Each field needs a key, a type and a label.

Field typeWhat the portal builder enters
textA text. maxLength limits its length
translated_textA text per language
numberA number. min, max and step constrain it
booleanA toggle
selectOne of the options you declare (value and label each)
entity_schemaAn entity schema. allowed limits the choice
pageA page of the portal
journeyA journey
color_tokenA color from the portal's design

Further field properties are description, required and default.

caution

Setting values reach the end customer's browser. Never use them for secrets: keep credentials in app options and use them server-side, for example through an API Proxy.

Increase version when you change the fields. A stored value that no longer fits a field falls back to the field's default.