Skip to main content

searchBlock

Search blocks by title.

Description​

Searches blocks by title in the given language and resolves to an array of ISearchBlock objects (id, identifier, name). Matching is case-insensitive and partial, so the method suits autocomplete.

.searchBlock(

,

);

Parameters schema​

Schema

name(required): string
Text to match against block titles in langCode. Matching is case-insensitive and partial.
example: "product_block"

langCode: string
Language code. Default: the langCode passed to defineOneEntry ("en_US" if none).
example: "en_US"

Examples​

Minimal example​

const response = await Blocks.searchBlock('Footer');

Example with langCode​

const response = await Blocks.searchBlock('Footer', 'en_US');

Example response​

[
{
"id": 12,
"identifier": "repeat",
"name": "Repeat"
},
{
"id": 10,
"identifier": "personal",
"name": "Personal"
},
{
"id": 9,
"identifier": "similar_wishlist",
"name": "Similar wishlist"
}
]

Response schema​

Schema: ISearchBlock[]

id: number
ID of the block.
example: 1

identifier: string
Marker of the block.
example: "search_block_1"

name: string
Title of the block in the requested language.
example: "Search Block 1"