Template code:
div class="drow">
{d:block module="postkeyproducts" cname="pro" mkey="key1" dbegin="row1|row2"}
h2>data.header}/h2>
div class="panelIdxPro1">
div class="dcol dscol w40 dtop">
{d:begin module="row1" thumb="250x0" loop="1"}
div class="box ma04">
div class="image mb2">a href="data.link}">data.picture}/a>/div>
div class="info mt2">
h3>a href="data.link}" class="lCyan">data.title}/a>/h3>
h4 class="proSameHeight">data.description}/h4>br>
h5>span class="price-old">data.cost_before}/span>span class="price-new">data.cost}/span>/h5>
/div>
/div>
{d:end}
/div>
div class="dcol dscol w60">
div class="drow groupSmall">
{d:begin module="row2" thumb="250x0" loop="1,6"}
div class="dcol dscol dmcol w33 dtop">
div class="box">
div class="image">a href="data.link}">data.picture}/a>/div>
div class="info">
h3>a href="data.link}" class="lCyan">data.title}/a>/h3>
/div>
/div>
/div>
{d:end}
/div>
/div>
/div>
{d:/block}
/div>
{d:block module="postkeyproducts" cname="pro" mkey="key1" dbegin="row1|row2"}
h2>data.header}/h2>
div class="panelIdxPro1">
div class="dcol dscol w40 dtop">
{d:begin module="row1" thumb="250x0" loop="1"}
div class="box ma04">
div class="image mb2">a href="data.link}">data.picture}/a>/div>
div class="info mt2">
h3>a href="data.link}" class="lCyan">data.title}/a>/h3>
h4 class="proSameHeight">data.description}/h4>br>
h5>span class="price-old">data.cost_before}/span>span class="price-new">data.cost}/span>/h5>
/div>
/div>
{d:end}
/div>
div class="dcol dscol w60">
div class="drow groupSmall">
{d:begin module="row2" thumb="250x0" loop="1,6"}
div class="dcol dscol dmcol w33 dtop">
div class="box">
div class="image">a href="data.link}">data.picture}/a>/div>
div class="info">
h3>a href="data.link}" class="lCyan">data.title}/a>/h3>
/div>
/div>
/div>
{d:end}
/div>
/div>
/div>
{d:/block}
/div>
Trong đó:
mkey: là tên khóa của danh mục sản phẩm cần hiển thị
dbegin: là tên khóa của khối các dòng dữ liệu cần lặp lại, có thể đặt tên tùy ý miễn sao trong cùng 1 khối thì không được có khóa trùng nhau. Trong phần này chúng ta đặt 2 khóa, các khóa cách nhau bằng dấu |. Ví dụ: dbegin="row1|row2" là các khối lặp theo khóa tương ứng với giá trị dbegin ở trên.
Ví dụ muốn row1 lặp lại 3 lần thì khai báo như sau:
{d:begin module="row1" thumb="250x0" loop="3"}
…
{d:end}
…
{d:end}
Muốn row2 hiển thị tiếp tục từ dữ liệu thứ 4 và hiển thị 5 dữ liệu ta khai báo như sau:
{d:begin module="row2" thumb="250x0" loop="4,5"}
…
{d:end}
…
{d:end}
Trong mỗi khối lặp ta điều chỉnh giao diện hiển thị khác nhau tùy theo nhu cầu sử dụng.
loop và thumb: là các thông số tương tự như trong phần Code hiển thị danh mục Sản phẩm.
Sử dụng cấu trúc trên ta có thể hiển thị kết quả như sau:
