Skip to navigation

Plan: Stencil Developer

Lesson 7 of 23 · 30 min

In this lab you will…

  • Add a new widget region to a Stencil template file
  • Create a global region
  • Place a widget in the global region

Prerequisites

  • BigCommerce sandbox store

This lab uses ‘Edit Theme Files’ as an ad hoc way to add regions to a theme. In a typical workflow, you would add regions to the theme’s template files locally with Stencil CLI, then bundle and deploy the theme to your store. To learn that setup and deploy workflow, see the Stencil Core course.

Add a Region

Add a new widget region to a Stencil template file

  1. Log in to the BigCommerce store that you have access to
  2. Navigate to ‘Storefront’ in the left navigation
  3. Click the ‘Advanced’ menu on the currently applied theme

Themes must be copied before the ‘Edit Theme Files’ option is available. You cannot edit the original version of the theme. Click the ‘Advanced’ menu on the theme, then ‘Make a Copy’ to copy your theme.

  1. Click ‘Edit Theme Files’
  2. Add the following code to the templates/pages/home.html template file:
{{{region name="home-top"}}}
templates/pages/home.html
{{#partial "page"}}
{{{region name="home-top"}}}
{{#each shipping_messages}}
{{> components/common/alert-info message}}
{{/each}}
...
  1. Click ‘Save File’ in the bottom right corner of the ‘Edit Theme Files’ window

Create a Global Region

  1. Log in to the BigCommerce store that you have access to
  2. Navigate to ‘Storefront’ in the left navigation
  3. Click the ‘Advanced’ menu on the currently applied theme
  4. Click ‘Edit Theme Files’
  5. Add the following code at the end of the ‘main full’ div tag in home.html to at the end of the ‘page-content’ div tag in category.html as shown in the examples below:
{{{region name="below_content--global"}}}
templates/pages/home.html
<div class="main full">
...
{{{region name="home_below_new_products"}}}
{{{region name="below_content--global"}}}
</div>
templates/pages/category.html
<main class="page-content" id="product-listing-container">
{{> components/category/product-listing}}
{{{region name="category_below_content"}}}
{{{region name="below_content--global"}}}
</main>

View the Regions in Makeswift

You can view the regions you added in Makeswift:

  1. Open the store control panel and go to the Channel Manager
  2. Select the Makeswift-connected channel and click Edit in Makeswift
  3. Navigate to the home page in the editor
  4. Observe the home-top region and the below_content—global region as places where you can add content

View the Regions in Page Builder

You can view the same regions in Page Builder:

  1. Navigate to channel manager > edit themes in the control panel
  2. Click Customize
  3. Launch Page Builder
  4. Scroll to the bottom of the home page
  5. Observe the below_content—global region under the non-global region below New Products

Place a Widget in the Global Region

Complete these steps in your editor of choice.

  1. Drag and drop one of the basic widgets into the below_content--global region
  2. Observe the widget you just placed displaying on the home page and the category pages of your store
  3. Publish the changes and view the live storefront