flyingL123
flyingL123

Reputation: 8076

Bigcommerce Stencil declare custom front-matter variable

I would like to define a list of featured category IDs within my homepage template. Is it possible to define a custom variable in the front matter? I can't seem to get it working:

Here is the default front-matter in templates/pages/home.html with my custom variable, featured_categories at the end:

---
products:
    new:
        limit: {{theme_settings.homepage_new_products_count}}
    featured:
        limit: {{theme_settings.homepage_featured_products_count}}
    top_sellers:
        limit: {{theme_settings.homepage_top_products_count}}
carousel: {{theme_settings.homepage_show_carousel}}
blog:
    recent_posts:
      limit: {{theme_settings.homepage_blog_posts_count}}
featured_categories: 'testing'
---

Then, in the template, this line is not producing any output:

{{featured_categories}}

Why doesn't this output the value testing? Ultimately, I would like featured_categories to be an array of category ID's. Is this possible to do using front matter?

Upvotes: 2

Views: 1401

Answers (1)

Alyss
Alyss

Reputation: 1866

It is not possible to declare a custom front matter variable as those have to be determined in the framework by BigCommerce. You can import handlebars yourself and define a variable, but it would execute client side and not server side for security reasons.

Upvotes: 1

Related Questions