Create a file called add_category into your modules, then put this code in it :
- <?php
- /*
- DynastyCMS
- Copyrigt (C) 2007 dynastycms
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- Custom made By Jo Boermans/Zblork31/Hoegarden31
- */
- if(!session_is_registered(Admin)) {
- die('Access Denied');
- }
- if(isset($_POST['submit'])) {
- $cat_hidden = 0;
- $cat_name = isset($_POST['cat_name']) ? mysql_real_escape_string($_POST['cat_name']) : null;
- $cat_desc = isset($_POST['cat_desc']) ? mysql_real_escape_string($_POST['cat_desc']) : null;
- $cat_minlevel = isset($_POST['cat_minlevel']) ? intval($_POST['cat_minlevel']) : 100;
- $cat_parent = isset($_POST['cat_parent']) ? intval($_POST['cat_parent']) : -1;
- $error = array();
- if(!$cat_name){
- $error[] = 'Name required!';
- }
- if(!$cat_minlevel){
- $cat_minlevel = 100;
- }
- if(!$cat_parent || $cat_parent == 0){
- $cat_parent = -1;
- }
- if(count($error) > 0){
- echo('<table width="100%" align="center">
- <tr>
- <td>Errors:</td>
- </tr>');
- foreach($error as $errors){
- echo('<tr>
- <td>'.$errors.'</td>
- </tr>');
- }
- echo('</table>');
- echo('<a href="?op=add_category"><==Go back</a>');
- }
- elseif(count($error) == 0){
- $sql = "INSERT INTO mall_category (ctitle,cdesc,cparent,cminlevel,chidden) VALUES ('%s','%s',%d,%d,%d);";
- $sql = sprintf($sql,$cat_name,$cat_desc,$cat_parent,$cat_minlevel,intval($cat_hidden));
- $res = @mysql_query($sql);
- echo 'Category added.';
- }
- } else {
- $all_cat = mysql_query("Select * FROM mall_category") or die(mysql_error());
- ?>
- <form id="form1" name="form1" method="post" action="?op=add_category">
- <table>
- <tr>
- <td>Categorie Name: </td>
- <td><input type="text" name="cat_name"></td>
- </tr>
- <tr>
- <td>Categorie Description: </td>
- <td><input type="text" name="cat_desc"></td>
- </tr>
- <tr>
- <td>Parent Categorie (if none is selected then it will be stored as a main category): </td>
- <td>
- <?php
- $html = '<select name="cat_parent">';
- $html .= '<option value='0'>None</option>';
- while ( $r = mysql_fetch_array($all_cat) ) {
- $html .= '<option value='.$r['cid'].'>'.$r['ctitle'].'</option>';
- }
- $html .= '</select>';
- echo($html);
- ?>
- </td>
- </tr>
- <tr>
- <td>Categorie Minimum level (Minimul GM level required to access the category): </td>
- <td><input type="text" name="cat_minlevel"></td>
- </tr>
- </table>
- <p align="center">
- <input name="submit" type="submit" id="submit" />
- <br />
- <br />
- </p>
- </form>
- <?php
- }
- ?>
Has you can see, i put by default hidden on 0. As there is no module to edit category's, you will have to put them manually in an hidden position if you want. Can be changed after a few comments
Then go into your admin menu, and add this code :
- <div id="nav_content">
- <div id="nav_top">Item Mall Management</div>
- <div id="nav_bottom">
- <a href="?op=add_category">Add categories</a><br />
- <a href="?op=add_items">Add items</a><br />
- <a href="?op=add_forsale">Add for sale items</a>
- </div>
- </div>
As you can see, i will make a module "add_items" and "add_forsale". When they are done, i will edit this post.
Hope this will help some players who don't really have the skills to edit tables in a database