load("templates/$config_template_store"); $template->replace("title", "CafeScripts Store - $catdesc[0]"); $template->replace("meta", "$catdesc[1]"); $template->replace("datetime", date("m/d/y")); if ($config_status == "closed" Or $config_status == "maintenance" Or $current_cat[1] == 1) //$current_cat[1] means current category is hidden { $status_message = "Our store is currently unavailable. Please check back later. We apologize for any inconvenience."; $template->replace("items", $status_message); $template->replace("search", ""); $template->replace("category_description", ""); $template->replace("random_item", ""); $template->replace("child_menu", ""); $template->replace("parent_menu", ""); $template->replace("pages", ""); $template->replace("banner", ""); $template->replace("cart_link", ""); $template->replace("search_bar", ""); } else { $template->replace("search", template_search()); $template->replace("category_description", $catdesc[2]); $template->replace("items", template_items()); $template->replace("random_item", template_random()); $template->replace("child_menu", template_child_menu()); $template->replace("parent_menu", template_parent_menu()); $template->replace("pages", template_pages()); $template->replace("banner", template_banner()); $template->replace("cart_link", cart_link()); $template->replace("search_bar", template_search_bar()); } $template->publish(); // TEMPLATE END //////////////////////////////////////////////////////// //////////////////////////////////////////////////////// // FUNCTIONS function template_items() { global $row; global $result; global $page; global $config_items_per_page; global $page_counter; global $config_store_img_local; global $config_web_path_small; global $config_display_style; global $counter; global $columns; global $category; $page_counter = 0; $items_result = "\n"; $items_result .= ''; while ($row = mysql_fetch_array($result)) { if ((($page-1)*$config_items_per_page) <= $page_counter And $page_counter <= (($config_items_per_page)*$page)-1) { if ($config_store_img_local == "yes") { $img = $config_web_path_small . $row[3] . "_sm.jpg"; } else { $img = $row[4]; } $items_result .= "\n"; // End outer table cell to hold table for item display $counter++; if ($counter % $columns == 0) { $items_result .= ""; } } $page_counter++; } $items_result .= "
\n"; // Outer table cell to hold table for item display $items_result .= ""; // Inner table to display item $namer=$row[0]; $namer = ereg_replace(" ", "", $namer); switch ($config_display_style) { case 'img_top': $items_result .= "\n"; $items_result .= "\n"; break; case 'img_bottom': $items_result .= "\n"; $items_result .= "\n"; break; case 'img_left': $items_result .= "\n"; $items_result .= "\n"; break; case 'img_right': $items_result .= "\n"; $items_result .= "\n"; break; } $items_result .= "
\n"; $items_result .= "\""
$row[0]
\$$row[1]
$row[0]
\$$row[1]
\n"; $items_result .= "\""\""$row[0]
\$$row[1]
$row[0]
\$$row[1]
\""
"; // End innter table to display item $items_result .= "

© 2005 NotOneBit.com. All rights reserved.

\n"; return $items_result; } function template_random() { global $config_display_random; global $random_item_data; $namer=$random_item_data[0]; $namer = ereg_replace(" ", "", $namer); if ($config_display_random == "yes") { $result = "Don't miss our other items like...
"; $result .= ""; $result .= "
"; $result .= $random_item_data[0] . "
"; $result .= "$" . $random_item_data[1] . "
"; } return $result; } function template_search() { $result = 'SEARCH'; return $result; } function template_search_bar() { $result = '
'; $result .= '
'; return $result; } function template_child_menu() { global $row1; global $parent_row; global $config_display_numitems; global $subcat_result; global $table_prefix; $result = ""; // List all subcategories of the current category (if any) while ($row1 = mysql_fetch_array($subcat_result)) { $catname=$row1[1]; #$catname = ereg_replace(" ", "", $catname); $catname = preg_replace(" ", "", $catname); if (!$row1[3]) { $result .= "»$row1[1]"; if ($config_display_numitems == "yes") { $itemcount_query = "SELECT * FROM " . $table_prefix . "listings WHERE category_id = '$row1[0]'"; $itemcount_result = mysql_query($itemcount_query) or die("Item count query failed"); $itemcount = mysql_num_rows($itemcount_result); while ($hidden_row = mysql_fetch_assoc($itemcount_result)) { $hidden_query = "SELECT hidden FROM " . $table_prefix . "items WHERE id = '$hidden_row[item_id]'"; $hidden_result = mysql_query($hidden_query) or die("Hidden item query failed"); $hidden_status = mysql_fetch_row($hidden_result); if ($hidden_status[0] == 1) $itemcount--; } if ($itemcount != 0) { $result .= " ($itemcount)"; } } $result .= "
"; } } if ($parent_row[0] != 0) { $result .= "
«Back
"; } return $result; } function template_parent_menu() { global $parent_row; global $current_cat; // Call function to build parent menu if ($parent_row[0] != 0) { $foo = build_parent_menu($parent_row[0]); } $result = $foo . "$current_cat[0]
"; return $result; } function build_parent_menu($pid) { // Recursive function to build parent menu global $parent_menu_string; global $parent_menu_array; global $table_prefix; // query for the name, id and parent_id of the $pid // add name & id to array // if $parent_id != 0 then // call function again with new parent_id // else return array $pid_query = "SELECT id, name, parent_id FROM " . $table_prefix . "categories WHERE id = '$pid'"; $pid_result = mysql_query($pid_query) or die("PID Query failed"); $pid_row = mysql_fetch_row($pid_result); $parent_menu_array[$pid_row[0]] = $pid_row[1]; $parent_menu_string = "$pid_row[1] » " . $parent_menu_string; if ($pid_row[2] != 0) { build_parent_menu($pid_row[2]); } return $parent_menu_string; } function template_pages() { global $result; global $config_items_per_page; global $page; global $category; $total_items = mysql_num_rows($result); $items_per_page = $config_items_per_page; // if we have more than 1 page and we're not on page 1, draw <> $pages = floor($total_items / $items_per_page); if ($total_items % $items_per_page != 0) { $pages++; } if ($pages >= 1) { $paginate_result .= "
Page: "; } if ($pages > 1 And $page != 1) { $prevpage = $page-1; $paginate_result .= "«Prev "; } for ($i=1; $i <= $pages; $i++) { if ($i == $page) { $paginate_result .= "" . $i . " "; } else { $paginate_result .= "$i "; } } if ($pages > 1 And $page != $pages) { $nextpage = $page+1; $paginate_result .= " Next»"; } return $paginate_result; } function template_banner() { global $config_show_promo_banner; global $config_show_referral_banner; global $config_show_special_banner; global $config_special_banner_code; global $banner_name; srand((double)microtime()*1000000); if ($config_show_promo_banner == "yes" And $config_show_referral_banner == "yes" And $config_show_special_banner == "yes") // (3) pick one of the three at random { $pick = rand(1,3); if ($pick == 1) { $result = ""; $result .= "\"Sale"; } elseif ($pick == 2) { $result .= ""; $result .= "\"Design"; } else { $result .= "$config_special_banner_code"; } } elseif ($config_show_promo_banner == "yes" And $config_show_referral_banner == "yes") // (2) pick one of the two at random { $pick = rand(1,2); if ($pick == 1) { $result .= ""; $result .= "\"Sale"; } else { $result .= ""; $result .= "\"Design"; } } elseif ($config_show_promo_banner == "yes" And $config_show_special_banner == "yes") // (2) pick one of the two at random { $pick = rand(1,2); if ($pick == 1) { $result .= ""; $result .= "\"Sale"; } else { $result .= "$config_special_banner_code"; } } elseif ($config_show_special_banner == "yes" And $config_show_referral_banner == "yes") // (2) pick one of the two at random { $pick = rand(1,2); if ($pick == 1) { $result .= "$config_special_banner_code"; } else { $result .= ""; $result .= "\"Design"; } } elseif ($config_show_promo_banner == "yes") // (1) show only promo banner { $result .= ""; $result .= "\"Sale"; } elseif ($config_show_referral_banner == "yes") // (1) show only referral banner { $result .= ""; $result .= "\"Design"; } elseif ($config_show_special_banner == "yes") // (1) show only special banner { $result .= "$config_special_banner_code"; } else { $result .= ""; } return $result; } function cart_link() { $str = "View Cart"; return $str; } // FUNCTIONS //////////////////////////////////////////////////////// mysql_close($connection); ?>