-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
51 lines (36 loc) · 1.46 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
//expanding mysql connection time out so we keep db on;
ini_set('mysql.connect_timeout', 3000);
ini_set('default_socket_timeout', 3000);
include('app\init.php');
$template->set_data('page_class', 'home');
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
// get products from specific category
$category = $categories->get_categories($_GET['id']);
// check if valid
if (! empty($category)) {
// get category nav
$category_nav = $categories->create_category_nav($category['name']);
$template->set_data('page_nav', $category_nav);
// get all products from that category
$cat_products = $products->create_product_table(4, $_GET['id']);
if (! empty($cat_products)) {
$template->set_data('prod_table', $cat_products);
} else {
$template->set_data('prod_table', '<li>No products exist in this category!</li>');
}
$template->load('app\views\v_home.php', $category['name']);
} else {
// if category isn't valid
$template->redirect(SITE_PATH);
}
} else {
// get all products from all categories
// get category nav
$category_nav = $categories->create_category_nav('home');
$template->set_data('page_nav', $category_nav);
// get products
$prod = $products->create_product_table();
$template->set_data('prod_table', $prod);
$template->load('app\views\v_home.php', 'FOX STore');
}