2017-05-08 52 views
1

我是Bigcommerce新手,也是Handlebars。我目前正在根據設計構建一個網站,並使用Merchant Stencil主題。如何訪問Bigcommerce模板主題對象

Here is a picture of the homepage structure I need

就目前而言,我存的是3段在home.html的模板文件,但我想帶來的產品信息(網址,名稱,描述)動態基於它的ID每個產品。

該店只銷售3種產品目前,我有一個特色產品部分與所有3個產品設置爲特色。這工作正常。第二部分是我想訪問Product ObjectProduct Card object(已添加文檔鏈接),我不知道該怎麼做。他們沒有代碼示例,我真的無法找到解決方法。任何幫助我如何使用這些對象將不勝感激。

我甚至問過Bigcommerce的支持,他們派我到這裏來。那裏的支持人員對他們的平臺上的發展毫無頭緒,所以他們把我送到了這裏。

乾杯!

這是我的home.html文件中的代碼。

{{#if products.featured}} 
<section class="products-featured section"> 
    <h4 class="section-title">{{lang 'home.featured_products'}}</h4> 
    <div class="wrapper"> 
     {{#each products.featured}} 
      {{> components/products/product-grid-item 
       quick_shop=../theme_settings.quick_shop 
      }} 
     {{/each}}    
    </div> 
</section> 
{{/if}} 
<section id="gg-one" class="glue-section"> 
    <div class="container"> 
     <div class="text-col"> 
      <h2 class="section-title">Grizzly One</h2> 
      <p class="caption-content">North America's first liquid polyurethane glue - a high-tech adhesive widely used by European woodworks and craftsmen for decades.</p> 
      <ul class="glue-feats"> 
       <li>Ideal for proffessional, commercial, and industrial woodworking needs.</li> 
       <li>Even bonds to oily and exotic woods!</li> 
      </ul> 
      <div class="buttons"> 

      </div> 
     </div> 
     <div class="img-col"> 

     </div>    
    </div> 
</section> 
<section id="gg-structan" class="glue-section"> 
    <div class="container"> 
     <div class="img-col"> 

     </div> 
     <div class="text-col"> 
      <h2 class="section-title">Grizzly Structan</h2> 
      <p class="caption-content">This heavy-bodied, cartridge-loaded 
      polyurethane adhesive is stronger than liquid polyurethane 
      glues.</p> 
      <ul class="glue-feats"> 
       <li>Perfect for wood, stone, tile, metal, and glass - dries to a tough elastic texture.</li> 
       <li>Industrial strength - ideal for professional and commercial applications.</li> 
      </ul> 
      <div class="buttons"> 

      </div> 
     </div> 
    </div> 
</section> 
<section id="gg-xpress" class="glue-section"> 
    <div class="container"> 
     <div class="text-col"> 
      <h2 class="section-title">Grizzly Xpress</h2> 
      <p class="caption-content">All the srength and body of a semi-gel adhesive<br> with a quick setting and curing time.</p> 
      <ul class="glue-feats"> 
       <li>The first and only semi-gel adhesive available in North America!</li> 
       <li>Quick, professional-strength bond for wood, stone, tile, metal and glass.</li>        
      </ul> 
      <div class="buttons"> 

      </div> 
     </div> 
     <div class="img-col"> 
      <div class="inner"> 
       <img src="https://cdn3.bigcommerce.com/s-jgnuwblrjb/product_images/uploaded_images/grizzly-xpress-home.png"> 
      </div> 
     </div> 
    </div> 
</section> 

回答

1

爲特色部分下面的動態部分創建一個組件。然後做

{{#each products.featured}} 
    {{> components/products/your-new-component }} 
{{/each}} 

您的組件內部,你會得到的產品對象,你可以通過簡單地{{product.id}}或{{product.title}}

獲取數據