Appearance
Premade sections
Premade sections are prepared sections, such as headers or footers, that users insert into an email in one click.
Define them with the premadeSections array in the TOPOL_OPTIONS object. The array holds one or more collections, each an object with a name for the collection and a blocks array containing the individual blocks. A collection name is required and shows as the group heading in the sidebar.
Each block takes a definition (its MJML structure) plus either an img or a name. The editor shows the image when img is set and falls back to the block's name otherwise.
In this example, the premadeSections array contains two collections, each with a single premade section.
ts
premadeSections: [
{
name: "Premade Sections Collection 1", // First collection of premade sections
blocks: [ // Premade section(s) within this collection
{
img: "https://placehold.co/600x400?text=Premade+Block", // Image URL, recommended width > 330px
name: "Premade Section 1", // Used if no Image URL is provided
definition: [
{
tagName: "mj-section",
attributes: {
"full-width": "600px",
padding: "10px 10px",
"mj-class": "section",
},
children: [
{
tagName: "mj-column",
attributes: { width: "100%", "vertical-align": "top" },
children: [
{
tagName: "mj-image",
attributes: {
src: "https://placehold.co/600x400?text=Image",
href: "https://yourwebsite.com",
alt: "Logo",
padding: "0px 0px 0px 0px",
"fluid-on-mobile": "false",
containerWidth: 600,
},
},
{
tagName: "mj-text",
attributes: {
align: "left",
padding: "15px 15px 15px 15px",
"line-height": 1.5,
containerWidth: 600,
},
content: "This is your premade section from the first collection",
},
],
},
],
},
],
},
],
},
{
name: "Premade Sections Collection 2", // Second collection of premade sections
blocks: [ // Premade section(s) within this collection
{
img: "https://placehold.co/600x400?text=Premade+Block",
name: "Premade Section 2",
definition: [
{
tagName: "mj-section",
attributes: {
"full-width": "600px",
padding: "10px 10px",
"mj-class": "section",
},
children: [
{
tagName: "mj-column",
attributes: { width: "100%", "vertical-align": "top" },
children: [
{
tagName: "mj-image",
attributes: {
src: "https://placehold.co/600x400?text=Image",
href: "https://yourwebsite.com",
alt: "Logo",
padding: "0px 0px 0px 0px",
"fluid-on-mobile": "false",
containerWidth: 600,
},
},
{
tagName: "mj-text",
attributes: {
align: "left",
padding: "15px 15px 15px 15px",
"line-height": 1.5,
containerWidth: 600,
},
content: "This is your premade section from the second collection",
},
],
},
],
},
],
},
],
},
],Advanced options
The Plugin includes a selection of premade section examples out of the box, grouped as Header, Content, E-commerce and Footer. Custom blocks can either replace those examples or sit alongside them, controlled by the boolean override option:
If
true, the editor removes the default groups and displays only what you list.If
false, the editor keeps the default groups. Any default group you do not place yourself is appended after your collections, in the order Header, Content, E-commerce, Footer.
To configure this option, update the basic premadeSections structure to the following advanced structure:
ts
premadeSections: {
blocks: PremadeSections[], // your collections and, optionally, preset markers
override: boolean // required when using this structure
}WARNING
override is required in the advanced structure. Omitting it fails validation, which leaves the editor with no premade sections at all and logs a parsing error. Set it explicitly to false to keep the defaults.
Placing the default groups
To decide where Topol's default groups appear, reference them inside blocks with a preset marker. A marker is an object with a single preset key and one of these values:
preset | Default group |
|---|---|
header | Header |
content | Content |
ecommerce | E-commerce |
footer | Footer |
The sidebar shows collections and markers in the order they appear in the array. This example puts a custom "Dynamic products" collection between Content and E-commerce:
ts
premadeSections: {
override: false,
blocks: [
{ preset: "header" },
{ preset: "content" },
{
name: "Dynamic products",
blocks: [
// your premade sections
],
},
{ preset: "ecommerce" },
{ preset: "footer" },
],
},A few rules apply:
- A marker is a bare reference. A marker with an extra
nameorblockskey fails validation. An object carrying all three keys is read as a custom collection, and itspresetkey is ignored. - Each preset can be listed once. Listing one twice fails validation.
- Markers work only in the advanced structure. A marker in the basic array fails validation.
- With
override: false, a default group you leave out is still appended at the end. Withoverride: true, it is left out. - The group's name and its blocks follow the editor language, so
ecommerceshows as "Produkty" with the Czech block set when the editor runs in Czech.
Like every other validation error on this option, a bad marker leaves the panel empty and logs Error while parsing premade blocks to the console with the failing path.
Transforming the basic structure to the advanced structure
Basic structure without the override option:
ts
premadeSections: [
{
name: "Premade Sections Collection 1",
blocks: [
{
img: "https://placehold.co/600x400?text=Premade+Block",
name: "Premade Section 1",
definition: [
{
// tagName, attributes, children...
},
],
},
],
},
],Advanced structure with the override option:
ts
premadeSections: {
blocks: [
{
name: "Premade Sections Collection 1",
blocks: [
{
img: "https://placehold.co/600x400?text=Premade+Block",
name: "Premade Section 1",
definition: [
{
// tagName, attributes, children...
},
],
},
],
},
],
override: false,
},To turn the feature off entirely, set premadeSections to false:
ts
premadeSections: false,Loading specific premade section examples
To keep only some of Topol's default groups, set override to true and list the ones you want as preset markers. This keeps only the Footer group next to your own collection:
ts
premadeSections: {
override: true,
blocks: [
{
name: "My collection",
blocks: [
// your premade sections
],
},
{ preset: "footer" },
],
},There is no built-in way to pick individual blocks out of a default group. To use only specific blocks:
- Use the advanced configuration structure and set the
overrideoption totrue. - Visit this GitHub Gist page, which contains the full definitions of all available premade section examples.
- Identify the blocks you'd like to use, then copy and paste their definitions into your own collection in
premadeSections.
