Search code examples
broadleaf-commerce

I Want To know The Thymeleaf Variable Location In Featured Products In Broadleaf


I Want To know What is the location of Thymeleaf variables in broadleaf home page. Please Help Me to Solve the Problem.

Here is the screenshot of the file and locaion:

file Screenshot: https://prnt.sc/gwtqun

i want to know the location of #object and featured products on that screen shot.

Thanks In Advance.


Solution

  • In Thymeleaf, the * and the #object both refer to the selected object in that context. http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#expressions-on-selections-asterisk-syntax

    In the HeatClinic demo, the productListItem.html template is referenced within several other templates where there are lists of products, such as groups of featured products, categories, and search.

    For example, in search.html:

    <ul th:if="${products}" id="products" class="js-products group">
        <li th:each="product : ${products}" th:object="${product}" th:include="catalog/partials/productListItem" class="js-productContainer productContainer"></li>
    </ul>
    

    Here you can see within the multiple nested instances of productListItem, the will be each of the products from the search. Those products are set on the model from the BroadleafSearchController by a call to model.addAttribute(...).


    Edit: In the HeatClinic demo's homepage.html in particular:

    <li th:if="${pageFields[product1]} and ${pageFields[product1].isActive()}" th:with="product=${pageFields[product1]}"
            th:object="${pageFields[product1]}" th:include="catalog/partials/productListItem"
            class="js-productContainer productContainer"></li>
    

    The pageFields attribute comes from the database table BLC_PAGE_FLD, where there is an entry with the key product1 and a value which is the product ID of the desired product (for example 1 in the demo). The controller which adds this object to the model is the BroadleafPageController.