Bigcommerce Stencil声明自定义的前端变量 [英] Bigcommerce Stencil declare custom front-matter variable
问题描述
我想在我的主页模板中定义精选类别ID列表。是否有可能在前面的问题中定义一个自定义变量?我似乎无法得到它的工作:
以下是 templates / pages / home.html $ c中的默认前端事项$ c>与我的自定义变量
featured_categories
结尾:
---
产品:
新:
限制:{{theme_settings.homepage_new_products_count}}
特色:
限制:{{theme_settings.homepage_featured_products_count}}
top_sellers:
限制:{{theme_settings.homepage_top_products_count}}
轮播:{{theme_settings.homepage_show_carousel}}
博客:
recent_posts:
限制:{{theme_settings .homepage_blog_posts_count}}
featured_categories:'testing'
---
然后,在该模板中,此行不会产生任何输出:
{{featured_categories}}
为什么不输出值测试
?最终,我希望 featured_categories
是类别ID的数组。这有可能做前面的事情吗?
不可能声明一个自定义的前端变量,由BigCommerce在框架中确定。您可以自己导入句柄并定义一个变量,但出于安全原因,它会执行客户端而不是服务器端。
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?
It is not possible to declare a custom front matter variable as those half 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.
这篇关于Bigcommerce Stencil声明自定义的前端变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!