Skip to main content

Text Builders

The SDK allows advanced users to override text building of some components with their own custom solution. This approach allows to avoid full overriding of component rendering (which can be hard), but just make some corrections in text.

This is achieved through the setCustomTextBuilder method. It accepts a configuration object with the following parameters:

KeyTypeDescription
sectionString - requiredThe key of the section that needs to be replaced (see the list of overridable sections below).
componentIdString - requiredThe ID of the experience component which the section belongs to
buildFunction - requiredThe custom text building function. It accepts predefined parameters (see the list of overridable sections below) and should return a string.
shouldOverrideFunctionA function that accepts the same parameters as build and must return a Boolean. If it returns true the custom text will be displayed.

Overridable text components

Text-only Media in tiles

Text which is displayed on text-only content tiles.

Key

FlexGridTileMediaTextOnly

Parameters
KeyDescription
tileObject, information about tile
productObject, all available information about UGC item
defaultTextText of caption (it's translated if this feature is used)

Note: see more info in Complex parameters definition section below.

Text-only Media in details view

Controls building of a Text only UGC text in the details view.

Key

FlexGridDetailsMediaTextOnly

Parameters
KeyDescription
productObject, all available information about UGC item
defaultTextText of caption (it's translated if this feature is used)

Note: see more info in Complex parameters definition section below.

Conversion units in details view

The conversion units, displayed on the right hand side in the details modal view.

Key

ConversionUnitGallery

Parameters
KeyDescription
conversionUnitsArray of conversion-unit objects

Note: see more info in Complex parameters definition section below.

Examples

Assuming you want to change text in text-only media in FlexGrid tile to display all text in capital letters, but only in big tiles and if the content comes from Twitter.

Here's what would go in the experience's custom JS section:

window.wyng['_WYNG_ID_'].setCustomTextBuilder({
section: `FlexGridTileMediaTextOnly`,
componentId: '[YOUR_COMPONENT_ID]',
shouldOverride: ({ tile, product }) => product.content.social_platform === 'twitter' && tile.isBigTile,
build: ({ product }) => `${product.content.text.toUpperCase()}`,
})