Prev | Current Page 244 | Next

Emilian Balanescu and Cristian Darie

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

link_to_category}">
{$obj->mCategories[i].name}


{/section}


{* End categories list *}
2. Create the presentation/categories_list.php file, and add the following code to it:
// Manages the categories list
class CategoriesList
{
// Public variables for the smarty template
public $mSelectedCategory = 0;
public $mSelectedDepartment = 0;
public $mCategories;
// Constructor reads query string parameter
public function __construct()
{
if (isset ($_GET['DepartmentId']))
$this->mSelectedDepartment = (int)$_GET['DepartmentId'];
else
trigger_error('DepartmentId not set');
if (isset ($_GET['CategoryId']))
$this->mSelectedCategory = (int)$_GET['CategoryId'];
}
CHAPTER 5 ?–  CREATING THE PRODUCT CATALOG: PART 2 153
public function init()
{
$this->mCategories =
Catalog::GetCategoriesInDepartment($this->mSelectedDepartment);
// Building links for the category pages
for ($i = 0; $i < count($this->mCategories); $i++)
$this->mCategories[$i]['link_to_category'] =
Link::ToCategory($this->mSelectedDepartment,
$this->mCategories[$i]['category_id']);
}
}
?>
3. Open the presentation/link.php file, and add the ToCategory() method shown below to Link
class. This method creates categories links.
public static function ToCategory($departmentId, $categoryId)
{
$link = 'index.php?DepartmentId=' . $departmentId .


Pages:
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
judo łódź Hotel SPA Jastrzębia Góra teksty piosenek wentylacja PokerStars