Prev | Current Page 183 | Next

Emilian Balanescu and Cristian Darie

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

= ':' . HTTP_SERVER_PORT;
}
$link = $base . VIRTUAL_LOCATION . $link;
// Escape html
return htmlspecialchars($link, ENT_QUOTES);
}
public static function ToDepartment($departmentId)
{
$link = 'index.php?DepartmentId=' . $departmentId;
return self::Build($link);
}
}
?>
2. Add two new constants to include/config.php:
// Server HTTP port (can omit if the default 80 is used)
define('HTTP_SERVER_PORT', '80');
/* Name of the virtual directory the site runs in, for example:
'/tshirtshop/' if the site runs at http://www.example.com/tshirtshop/
'/' if the site runs at http://www.example.com/ */
define('VIRTUAL_LOCATION', '/tshirtshop/');
3. Modify the init() method from the DepartmentsList class in presentation/departments_
list.php as shown in the highlighted code:
/* Calls business tier method to read departments list and create
their links */
public function init()
{
// Get the list of departments from the business tier
$this->mDepartments = Catalog::GetDepartments();
// Create the department links
for ($i = 0; $i < count($this->mDepartments); $i++)
$this->mDepartments[$i]['link_to_department'] =
Link::ToDepartment($this->mDepartments[$i]['department_id']);
}
CHAPTER 4 ?–  CREATING THE PRODUCT CATALOG: PART 1 109
4. Create a new file named store_front.php in the presentation folder, and add the following code to it.
This is the presentation object that we??™ll use for the store_front template, and it builds a link to the main
page of the site.


Pages:
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195