summaryrefslogtreecommitdiffstats
path: root/categories.php
diff options
context:
space:
mode:
Diffstat (limited to 'categories.php')
-rw-r--r--categories.php66
1 files changed, 7 insertions, 59 deletions
diff --git a/categories.php b/categories.php
index 0425ec1..7760655 100644
--- a/categories.php
+++ b/categories.php
@@ -1,63 +1,11 @@
<?php
session_start();
-?>
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="UTF-8">
-<title>Categories</title>
-<link rel="stylesheet" type="text/css" href="styles/style.css">
-</head>
-<body>
-<header><h1>Categories</h1></header>
-<nav>
-<dl>
-<dt><a href="contact.php">Contact us</a></dt>
-<dt><a href=".">Home</a></dt>
-<?php
-if(isset($_SESSION['username']))
-{
- echo "<dt><a href=\"login.php?logout\">Logout</a></dt>";
- $username = $_SESSION['username'];
-}
-else
-{
- echo "<dt><a href=\"login.php\">Login</a></dt>";
-}
-?>
-</dl>
-</nav>
-<div id="content">
-<table>
-<?php
- require_once('vendor.inc.php');
+require_once('vendor.inc.php');
+
+$smarty = new Smarty;
- $categories = CategoryQuery::create()->find();
+$smarty->assign('loggedin', isset($_SESSION['username']));
+$smarty->assign('categories', CategoryQuery::create()->find());
- foreach( $categories as $category ){
- echo "<tr>";
- echo "<td><a href=\"products.php?id={$category->getId()}\">{$category->getName()}</a></td>";
- echo "<td>{$category->getDescription()}</td>";
- if(isset($username))
- {
- echo "<td><a href=\"categoryedit.php?modify={$category->getId()}\">Edit</a></td>";
- echo "<td><a href=\"categoryedit.php?delete={$category->getId()}\" onClick=\"return confirm('Confirm deletion.')\">Delete</a></td>";
- }
- echo "</tr>";
- }
- if(isset($username))
- {
- echo "<tr>";
- echo "<td></td>";
- echo "<td></td>";
- echo "<td></td>";
- echo "<td><a href=\"categoryedit.php?add\">Add</a></td>";
- echo "</tr>";
- }
-?>
-</table>
-<div class="spacer"></div>
-</div>
-<footer>Copyright by SomeCompany Ltd.</footer>
-</body>
-</html> \ No newline at end of file
+$smarty->display('categories.tpl');
+?> \ No newline at end of file