Integrate Symbols
Symbols are a type of Section model you can integrate for editing on your site or app. They help you elegantly reuse content across many Builder Pages and Sections. For more information, see Intro to Symbols.
Prerequisites
To get the most out of this document, you should have:
Add Symbol editing to your app
Create a special page on your site specifically for Symbol editing. This is what the Builder preview opens when you create and edit symbols. It's important this be on a URL directly on your site, so all previewing and editing are accurate.
In this example, this page is named /edit-symbol.
Create a page with the following contents. Make sure to replace YOUR_API_KEY with your Public API Key:
BuilderComponent gives the drag and drop Visual Editor a region to work in in your site.
Note that if you have registered custom components, you must import them on this page so that they are available in the Visual Editor.
Create a page with the following contents. Make sure to replace YOUR_API_KEY with your Public API Key:
Content allows the drag and drop editor to work in the specified region of your site.
Note that if you have registered custom components, you must import them on this page so that they are available in the Visual Editor.
Create a page with the following contents. Make sure to replace YOUR_API_KEY with your Public API Key:
BuilderComponent allows the drag and drop editor to work in the specified region of your site.
Note that if you have registered custom components, you must import them on this page so that they are available in the Visual Editor.
Create a page with the following contents. Make sure to replace YOUR_API_KEY with your Public API Key:
Content allows the drag and drop editor to work in the specified region of your site.
Note that if you have registered custom components, you must import them on this page so that they are available in the Visual Editor.
Create a page with the following contents. Make sure to replace YOUR_API_KEY with your Public API Key:
BuilderComponent allows the drag and drop editor to work in the specified region of your site.
Note that if you have registered custom components, you must import them on this page so that they are available in the Visual Editor.
Create a page with the following contents. Make sure to replace YOUR_API_KEY with your Public API Key:
Content allows the drag and drop editor to work in the specified region of your site.
Note that if you have registered custom components, you must import them on this page to be available in the Visual Editor.
Paste the following code into a new file within the routes directory called $.tsx, making sure to replace YOUR_API_KEY with your Public API Key.
The BuilderComponent provides a place for the Builder content model named symbol to render.
Add the following to routes/edit-symbol/+page.svelte:
Add the following to src/routes/edit-symbol/+page.ts:
Make sure to replace YOUR_API_KEY with your Public API Key.
Create a file called pages/edit-symbol.vue with the following contents. Make sure to replace YOUR_API_KEY with your Public API Key:
Content allows the drag and drop editor to work in the specified region of your site.
Create a page with the following contents:
BuilderComponent allows the drag and drop editor to work in the specified region of your site.
Note that if you have registered custom components, you will need to import them on this page so that they are available in the Visual Editor.
Fetch your announcement bar's pre-rendered HTML from Builder's HTML API. Then inject it into your app's page template.
The example below uses Express.js.
Make sure to replace YOUR_API_KEY with your Public API Key.
Add a new component for this demo using the Angular CLI tool, which will load the announcement bar section in your app:
Replace the placeholder content in your component's template with the following:
Now, be sure to connect this component to your router so that it renders for /edit-symbol
For instructions on getting your Public API Key, see Finding Your Public API Key in Using Builder API Keys.
Update your Symbol Preview URL
- Go to Models and choose the Symbol model. If you don't have Symbol here, make sure that you've met the prerequisite of having created a Symbol. For step-by-step instructions, read Making a Symbol.
- Enter your site domain at a specifc path, such as
/edit-symbol, for examplehttps://my-site.com/edit-symbol. - Click Save.
You can use localhost when testing locally, then change to a hosted URL like your QA or production URL once your code updates have been deployed.
For more examples of what you can do with Builder, check out the Blueprints, which cover varied use cases at a high-level with code examples.