"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"
This creates the link to the edit product administration page. // Build links for product departments and categories pages for ($i = 0; $i < count($this->mLocations); $i++) { $this->mLocations[$i]['link_to_department'] = Link::ToDepartment($this->mLocations[$i]['department_id']); $this->mLocations[$i]['link_to_category'] = Link::ToCategory($this->mLocations[$i]['department_id'], $this->mLocations[$i]['category_id']); } // Prepare the Edit button $this->mEditActionTarget = Link::Build(str_replace(VIRTUAL_LOCATION, '', getenv('REQUEST_URI'))); if (isset ($_SESSION['admin_logged']) && $_SESSION['admin_logged'] == true && isset ($_POST['submit_edit'])) { $product_locations = $this->mLocations; if (count($product_locations) > 0) { $department_id = $product_locations[0]['department_id']; $category_id = $product_locations[0]['category_id']; header('Location: ' . htmlspecialchars_decode( Link::ToProductAdmin($department_id, $category_id, $this->_mProductId))); CHAPTER 11 ?– CATALOG ADMINISTRATION: PRODUCTS AND ATTRIBUTES 355 } } } } ?> 10. Add the following piece of code to presentation/templates/products_list.tpl. This adds the Edit buttons to the product lists. {* Add the submit button and close the form *}
{* Show Edit button for administrators *} {if $obj->mShowEditButton}