In the final part of the function, you added the link_to_product and thumbnail data to each $mProducts
record, which contain, respectively, the link to the product??™s page and its thumbnail file name. These values are
used in the template file to display the product images and create links to the product pages on the products??™
names and pictures. The links are created using the Link::ToProduct() and Link::Build() methods:
// Build links for product details pages
for ($i = 0; $i < count($this->mProducts); $i++)
{
$this->mProducts[$i]['link_to_product'] =
Link::ToProduct($this->mProducts[$i]['product_id']);
if ($this->mProducts[$i]['thumbnail'])
$this->mProducts[$i]['thumbnail'] =
Link::Build('product_images/' . $this->mProducts[$i]['thumbnail']);
}
We??™ve also modified the methods of the Link class to add the Page parameter to the query string, if the page
number is greater than 1. This is now necessary since adding product lists to our catalog implies supporting the
paging functionality.
if ($page > 1)
$link .= '?Page=' . $page;
Displaying Front Page Contents
Apart from general information about the web site, you also want to show some promotional
products on the first page of TShirtShop.
If the visitor browses a department or a category, the department Smarty template is used
to build the output. For the main web page, we??™ll create the first_page_contents componentized
template that will build the output.
Pages:
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265