Prev | Current Page 250 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

$this->mProducts[$i]['thumbnail']);
}
}
}
?>
5. Modify presentation/link.php as highlighted here to add a new method to the Link class called
ToProduct(), which creates links to product pages. Also, we??™ll add the parameter $page to the two existing
methods, ToDepartment() and ToCategory(), and the code needed for pagination.
public static function ToDepartment($departmentId, $page = 1)
{
$link = 'index.php?DepartmentId=' . $departmentId;
if ($page > 1)
$link .= '&Page=' . $page;
return self::Build($link);
}
public static function ToCategory($departmentId, $categoryId, $page = 1)
{
$link = 'index.php?DepartmentId=' . $departmentId .
'&CategoryId=' . $categoryId;
if ($page > 1)
$link .= '&Page=' . $page;
return self::Build($link);
}
public static function ToProduct($productId)
{
return self::Build('index.php?ProductId=' . $productId);
}
}
?>
CHAPTER 5 ?–  CREATING THE PRODUCT CATALOG: PART 2 161
6. Open presentation/templates/department.tpl and replace
Place list of products here
with
{include file="products_list.tpl"}
7. Load your project in your favorite browser; navigate to one of the departments; and then select a category
from a department. Also, find a category with more than four products to test that the paging functionality
works, as shown earlier in Figure 5-10.
How It Works: The products_list Componentized Template
Because most functionality regarding the products list has already been implemented in the data and business
tiers, this task was fairly simple.


Pages:
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262