Open the link.php file located in the presentation folder, and add the following method to the
Link class:
public static function ToIndex($page = 1)
{
$link = '';
if ($page > 1)
$link .= 'index.php?Page=' . $page;
return self::Build($link);
}
5. Load your project in your favorite browser. The result should look like Figure 5-11.
Figure 5-11. The front page of TShirtShop
How It Works: The first_page_contents Componentized Template
The actual list of products is still displayed using the products_list Smarty componentized template, which
you built earlier in this chapter. However, this time, it isn??™t loaded from department.tpl (like it loads when
browsing a department or a category) but from a new template file named first_page_contents.tpl.
We added new functionality to the init() method in the ProductsList class for displaying the products to be
featured on the first page of the site. Also, we created the ToIndex() method in the Link class to support pagination
for the first page of the site.
CHAPTER 5 ?– CREATING THE PRODUCT CATALOG: PART 2 166
Showing Product Details
The last bit of code you??™ll implement in this chapter is about displaying product details. When
a visitor clicks any product, he or she will be forwarded to the product??™s details page, which
shows the product??™s complete description and the secondary product image.
Pages:
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268