WebReinvent Internal Docs
Builderio Nuxt 3

Section Model

A Section model describes a portion of a Page that your teammates can use in the Visual Editor. Use Section models to define editable parts of Pages, such as:

Like Pages, you use Sections in the Visual Editor's drag-and-drop interface. Unlike Pages, however, a URL is optional for Sections.

The following image outlines an Add Block area of a Page. This area, a Section, is only a part of the Page. Section model

With Sections, you can create your Section and then use targeting and querying to make it display in the right place at the right time. For more information, refer to Targeting Content and Scheduling Content.

Finding Section models

To view the details of a Section model in a Space, do the following:

  1. Go to the Models section of the Builder UI.
  2. Select the Section model.

From within the Section model, you can edit and add fields. For details on fields in models, refer to Custom Fields.

The following video demonstrates the above steps for locating and opening a model. In this example, the Section model is named Blog article.

Creating Section models

You can create Section models for any area of a Page. Section models are perfect for variations and iterating You can create as many as you like.

To create and use a Section model, do the following:

  1. Go to the Models section of the Builder UI.
  2. Click the + Create Model button.
  3. Choose Section.
  4. In the Model Display name field, enter the name you'd like this model to have when listed in the Models section of Builder. You can edit this later if you change your mind.
  5. Name the model and fill out the Model Description field.
  6. Click Create.
  7. Add any needed custom fields.
  8. Click Save.

To use the new Section model, integrate with your codebase and then your teammates can create content entries in the Visual Editor.

The following video shows how to create an example Blog article Section model then shows how to use the new model to create a content entry:

Integrating Section Models

These are the steps to Integrate Section Model in your page.

Steps for setup

1) Create a page with the following contents.

<template>
  <div>
    // Your page content above section
    <div v-if="content" >
      <Content
          model="section-model"
          :content="content"
          :apiKey="config.public.builderApiKey"
      />
    </div>
    // Your page content below section
  </div>
</template>

2) builderApiKey is set into the .env and after that you have to configure into nuxt.config.ts file which you can use by using useRuntimeConfig composable.

<script setup>
import {fetchOneEntry, Content} from '@builder.io/sdk-vue';
const route = useRoute();
const config = useRuntimeConfig();

const content = await fetchOneEntry({
  model: "section-model",
  apiKey: config.public.builderApiKey,
  userAttributes: {
    urlPath: route.path,
  },
})
</script>

Copyright © 2024