4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: byrev on December 22, 2006, 11:06:29 PM

Title: [MOD] Add Multiple Categories/Subcategories, one time with single Click!
Post by: byrev on December 22, 2006, 11:06:29 PM
With this modification you can add in "ACP -> Add Categories " several categories with one single click !


if i have 400 category i must lose days with simple procedure ... ;)
modify function for multiple category/subcategory one time, one click !!!

========= This is my modification code for this job ===========
Code: [Select]
  if (empty($error)) {
$cat_name_array = explode('|', $cat_name);
$cat_name_count = count($cat_name_array);
    for ($i=0;$i<$cat_name_count;$i++)
    {     
    $cat_name = $cat_name_array[$i];   
/** Start ADD **/
    if (!$cat_order) {         
      $sql = "SELECT cat_order
              FROM ".CATEGORIES_TABLE."
              WHERE cat_parent_id = $cat_parent_id
              ORDER BY cat_order DESC
              LIMIT 1";
      $catorder = $site_db->query_firstrow($sql);
      $cat_order = $catorder['cat_order'] + 10;
      $do_update_cat_order = 0;
    }
    else {
      $do_update_cat_order = 1;
    }
         
     $sql = "INSERT INTO ".CATEGORIES_TABLE."
            (cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment)
            VALUES
            ('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment)";
     $result = $site_db->query($sql);
     $cat_id = $site_db->get_insert_id();

     if ($result && $cat_id) {
      if ($do_update_cat_order) {
        update_cat_order($cat_parent_id);
      }
      $msg = $lang['cat_add_success'];
      create_cat_folder(MEDIA_PATH."/".$cat_id, CHMOD_DIRS);
      create_cat_folder(THUMB_PATH."/".$cat_id, CHMOD_DIRS);
     }
     else {
      $msg = $lang['cat_add_error'];
     }
     /** End ADD **/
     // echo $cat_name.' , ';
    } // end FOR!
    forward_to_modify($msg);   
  }

modification in: admin/categories.php
position: in body "savecat" action: if ($action == "savecat") {

so....
now you can enter categories like this example:
Animals|Cars|Bussines|Nature|Musical|Sports|Abstract|Art|People|Objects|Musical|Food|Education
and .. done ... 13 categories with only 1 click !!! ;)

This modification works here : http://www.findavatar.com

Edited by mawenzi :
- how to add the modification : here (http://www.4homepages.de/forum/index.php?topic=15913.msg86460#msg86460)
- how to add APC description extension : here (http://www.4homepages.de/forum/index.php?topic=15913.msg87519#msg87519)
Title: Re: Multiple Category/Subcategory, one time with single Clik!
Post by: alemao59 on January 13, 2007, 08:21:00 PM
hi,
where do i have tto add this code? do i need to replace anything? thanks
Title: Re: Multiple Category/Subcategory, one time with single Clik!
Post by: byrev on January 14, 2007, 11:05:22 AM
in file: categories.php from admin folder  ( ./admin/categories.php )
find first aparence: if (empty($error)) {
for me i find this at line 502.
now form 502 to 537 you have this code:
Quote
  if (empty($error)) {
    if (!$cat_order) {
      $sql = "SELECT cat_order
              FROM ".CATEGORIES_TABLE."
              WHERE cat_parent_id = $cat_parent_id
              ORDER BY cat_order DESC
              LIMIT 1";
      $catorder = $site_db->query_firstrow($sql);
      $cat_order = $catorder['cat_order'] + 10;
      $do_update_cat_order = 0;
    }
    else {
      $do_update_cat_order = 1;
    }

    $sql = "INSERT INTO ".CATEGORIES_TABLE."
            (cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment)
            VALUES
            ('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment)";
    $result = $site_db->query($sql);
    $cat_id = $site_db->get_insert_id();

    if ($result && $cat_id) {
      if ($do_update_cat_order) {
        update_cat_order($cat_parent_id);
      }
      $msg = $lang['cat_add_success'];
      create_cat_folder(MEDIA_PATH."/".$cat_id, CHMOD_DIRS);
      create_cat_folder(THUMB_PATH."/".$cat_id, CHMOD_DIRS);
    }
    else {
      $msg = $lang['cat_add_error'];
    }
    //$action = "modifycats";
    forward_to_modify($msg);
  }

Replace code from line 502 to 537, with the next code:
Quote
  if (empty($error)) {
   $cat_name_array = explode('|', $cat_name);
   $cat_name_count = count($cat_name_array);
    for ($i=0;$i<$cat_name_count;$i++)
    {     
    $cat_name = $cat_name_array[$i];   
   /** Start ADD **/
    if (!$cat_order) {         
      $sql = "SELECT cat_order
              FROM ".CATEGORIES_TABLE."
              WHERE cat_parent_id = $cat_parent_id
              ORDER BY cat_order DESC
              LIMIT 1";
      $catorder = $site_db->query_firstrow($sql);
      $cat_order = $catorder['cat_order'] + 10;
      $do_update_cat_order = 0;
    }
    else {
      $do_update_cat_order = 1;
    }
         
     $sql = "INSERT INTO ".CATEGORIES_TABLE."
            (cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment)
            VALUES
            ('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment)";
     $result = $site_db->query($sql);
     $cat_id = $site_db->get_insert_id();

     if ($result && $cat_id) {
      if ($do_update_cat_order) {
        update_cat_order($cat_parent_id);
      }
      $msg = $lang['cat_add_success'];
      create_cat_folder(MEDIA_PATH."/".$cat_id, CHMOD_DIRS);
      create_cat_folder(THUMB_PATH."/".$cat_id, CHMOD_DIRS);
     }
     else {
      $msg = $lang['cat_add_error'];
     }
     /** End ADD **/
     // echo $cat_name.' , ';
    } // end FOR!
    forward_to_modify($msg);   
  }

Done... must be ok now !!!
Title: Re: Multiple Category/Subcategory, one time with single Clik!
Post by: byrev on January 14, 2007, 11:12:58 AM
i see many scripts: cms, forum, blogs, gallery... no one have this modification... wtf, i am to smart for this job !!!
i made similar modification to wordpress, runcms, Jupiter CMS and ... other scripts !!! works all time :)
Title: Re: Multiple Category/Subcategory, one time with single Clik!
Post by: trez on January 31, 2007, 09:22:37 AM
i see many scripts: cms, forum, blogs, gallery... no one have this modification... wtf, i am to smart for this job !!!
i made similar modification to wordpress, runcms, Jupiter CMS and ... other scripts !!! works all time :)

Oh, how good you bless us too with that modification  8)
At least can you tell a little bit more what this is about? I get a little confused.
It's a "multiple category maker" ? If yes, great job ;)
Title: Re: Multiple Category/Subcategory, one time with single Clik!
Post by: mawenzi on January 31, 2007, 03:07:09 PM
@ byrev

... I've just tested your modification in ACP -> Add Categories ...
... it works great ...  :!:
... but we should add some description in ACP "Add Categories" ...
... so that in ACP everyone can read how to add multiple categories ...
Title: Re: [MOD] Multiple Category/Subcategory, one time with single Clik!
Post by: mawenzi on January 31, 2007, 03:54:02 PM
... my little description extension in APC, to know / to read how to add multiple categories ...  :wink:

1. Step
find in /admin/categories.php the following ...
Code: [Select]
show_input_row($lang['field_category_name'], "cat_name", "", $textinput_size);
and replace with ...
Code: [Select]
show_input_row($lang['field_category_name_ext'], "cat_name", "", $textinput_size);

2. Step - Deutsch
find in /lang/deutsch/admin.php in section //---Fields --- the following ...
Code: [Select]
$lang['field_category_name'] = "Kategorie Name";
and add after ...
Code: [Select]
$lang['field_category_name_ext'] = "Kategorie Name<br /><span class=\"smalltext\">Es können mehrere Kategorien hinzugefügt werden.<br>Dann sind die Kategorie-Namen durch | zu trennen. z.B. Test1|Test2|Test3</span>";

2. Step - English (only my insignificant English)
find in /lang/english/admin.php in section //---Fields --- the following ...
Code: [Select]
$lang['field_category_name'] = "Category name";
and add after ...
Code: [Select]
$lang['field_category_name_ext'] = "Category name<br /><span class=\"smalltext\">You can add several categories.<br>Then you must separate category names through | . e.g. Test1|Test2|Test3</span>";

... btw ... nice modification ...  :D

PS.
@  Acidgod ... dieser Topic kann nach Mods & Plugins verschoben werden ... Danke !
Title: Re: [MOD] Multiple Category/Subcategory, one time with single Clik!
Post by: Acidgod on January 31, 2007, 03:56:31 PM
Gesagt getan... (o:
Title: Re: [MOD] Add Multiple Categories/Subcategories, one time with single Click!
Post by: Tiburon on March 16, 2007, 10:53:16 AM
hm, it does not work in 1.7.4  :cry:
Title: Re: [MOD] Add Multiple Categories/Subcategories, one time with single Click!
Post by: mawenzi on March 16, 2007, 11:21:26 AM
... tested also on a version 1.7.4 ... and it works great ... ;)
Title: Re: [MOD] Add Multiple Categories/Subcategories, one time with single Click!
Post by: Jenn on March 16, 2007, 03:25:58 PM
Worked Beautifully on 1.7.4 as well :)

Thanks for this. Helps out alot.
Title: Re: [MOD] Add Multiple Categories/Subcategories, one time with single Click!
Post by: 4ella on June 01, 2009, 01:54:31 PM
Great modification , works good in 1.7.6 too
Title: Re: [MOD] Add Multiple Categories/Subcategories, one time with single Click!
Post by: truecolor on June 04, 2009, 03:25:12 AM
simulation credit auto (http://simulationcreditauto.net/)
This worked really well. Many thanks  8)
Title: Re: [MOD] Add Multiple Categories/Subcategories, one time with single Click!
Post by: khansahib on December 28, 2010, 12:11:57 PM
Amazing, You saved alot of my Time....
just a thought can same be done with adding description to the categories..

Like

cat1|cat2|cat3
desc1|desc2|desc3

Thanks :)
Title: Re: [MOD] Add Multiple Categories/Subcategories, one time with single Click!
Post by: Bodzio on November 11, 2012, 10:08:24 PM
Can anyone help?

The categories are not placed in order, when I add Test1|Test2 etc. it goes randomly after adding.

Can anyone help with thesame thing with adding many descriptions at once?