Custom Catagories

Discussion in 'Requests' started by Jake Blumenow, Feb 27, 2017.

  1. Jake Blumenow

    Jake Blumenow New Member

    Joined:
    Jan 25, 2017
    Messages:
    19
    Likes Received:
    1
    How would I let users come up with their own Sub Categories;

    For example, If I was to click on the Electronics Category, How would I make it so that the user can then write their own sub category that would appear as a category in Browse?

    Many Thanks
     
  2. hhavatar

    hhavatar Donor Donor

    Joined:
    Jul 28, 2014
    Messages:
    747
    Likes Received:
    74
    Tricky one. You'll have to copy some of the code from /admin/categories.php and set the system to only pull categories at the second highest number level you have in the categories sql table. Can be done.
     
  3. Jake Blumenow

    Jake Blumenow New Member

    Joined:
    Jan 25, 2017
    Messages:
    19
    Likes Received:
    1
    PHP:
        //add category if need be
            
    if (!empty($_POST['new_category']) && isset($_POST['parent']))
            {
                
    $add_data = array(
                    
    'cat_name' => $_POST['new_category'],
                    
    'cat_colour' => $_POST['cat_colour'],
                    
    'cat_image' => $_POST['cat_image']
                    );
                
    $catscontrol->add($_POST['parent'], 0$add_data);
            }
    I understand this is the code I would need to use, what would I need to put at the beginning, e.g. include what?
     
  4. nay27uk

    nay27uk Super Moderator Staff Member

    Joined:
    Nov 24, 2009
    Messages:
    5,572
    Likes Received:
    547
    There is a lot more to it than just the code you have above.
    You would also need any code from the below listed files and possibly even more code from even more files than listed below from the admin side.

    includes
    functions_admin.php
    ,
    class_MPTTcategories.php

    admin

    categories.php,
    categoriestrans.php,
    catsorting.php

    You would also need to add the forms from the admin category tpl pages to the user side tpl pages and the theme in admin works totally different to the user side themes, the admin side uses Blocks so you would also need to include any code from whatever file deals with blocks in the admin side and add that code somewhere to the user side.

    Personally I would just give up on this idea now if I where you, unless you know someone that is a genius coder.

    I have tried to do things like this in the past and I have never achieved it.

    There are just so many differences and files involved on how the admin and user sides work for the categories, there are just far to many elements to how the categories work on both sides in WeBid.

    The categories are not just a case of a few database tables or even table columns, there are also text files involved with the categories (language/EN/categories.inc.php) as well as the tables and columns in the database that deal with categories also being related and linked to other tables and columns in the database, auctions table and users tables are 2 examples and there are more tables and columns in the database that are all linked to the categories.

    Personally I would just add a link to the tpl files that says "Request a Sub Category here" that when clicked on would open the users email software with a pre filed out Title and Subject that would then email the admin with a category suggestion, A friend of mine on the forums andre88uk did make a WeBid mod for this back in the old WeBid 0.7.3 days that had 2 links one for "suggest a sub category here" and one for "sell in this category" if the category was empty I think the original thread is still available HERE.

    The above mod that I suggest should be very easy to implement and saves trying to work out how the whole category system in webid works an almost impossible task.
     
    Last edited: Mar 7, 2017
    Sean.T33 likes this.

Share This Page