4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 22, 2014, 08:13:08 PM

Login with username, password and session length
Search:     Advanced search
Togle to toolbar
Translate this page with =>
Translate this page >
* Home Help Search Login Register
 
+  4images Forum & Community
|-+  4images Modifications / Modifikationen
| |-+  Mods & Plugins (Releases & Support) (Moderators: mawenzi, Rembrandt)
| | |-+  [MOD] Add Multiple Categories/Subcategories, one time with single Click!
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
This topic has not yet been rated!
Author Topic: [MOD] Add Multiple Categories/Subcategories, one time with single Click!  (Read 13868 times)
byrev
Pre-Newbie

Offline Offline

Posts: 4

Thank You
-Given: 0
-Receive: 0


View Profile
« 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 ... Wink
modify function for multiple category/subcategory one time, one click !!!

========= This is my modification code for this job ===========
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
  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 !!! Wink

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

Edited by mawenzi :
- how to add the modification : here
- how to add APC description extension : here
« Last Edit: January 31, 2007, 04:24:25 PM by mawenzi » Logged
alemao59
Pre-Newbie

Offline Offline

Posts: 3

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #1 on: January 13, 2007, 08:21:00 PM »

hi,
where do i have tto add this code? do i need to replace anything? thanks
Logged
byrev
Pre-Newbie

Offline Offline

Posts: 4

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #2 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  [Expand]
  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  [Expand]
  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 !!!
Logged
byrev
Pre-Newbie

Offline Offline

Posts: 4

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #3 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 Smile
Logged
trez
Hero Member
*****
Offline Offline

Posts: 612

Thank You
-Given: 12
-Receive: 22


View Profile WWW
« Reply #4 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 Smile

Oh, how good you bless us too with that modification  Cool
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 Wink
Logged

mawenzi
Moderator
4images Guru
*****
Offline Offline

Posts: 4500

Thank You
-Given: 36
-Receive: 119


View Profile
« Reply #5 on: January 31, 2007, 03:07:09 PM »

@ byrev

... I've just tested your modification in ACP -> Add Categories ...
... it works great ...  Exclamation
... but we should add some description in ACP "Add Categories" ...
... so that in ACP everyone can read how to add multiple categories ...
Logged

Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...
mawenzi
Moderator
4images Guru
*****
Offline Offline

Posts: 4500

Thank You
-Given: 36
-Receive: 119


View Profile
« Reply #6 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 ...
1
show_input_row($lang['field_category_name'], "cat_name", "", $textinput_size);
and replace with ...
1
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 ...
1
$lang['field_category_name'] = "Kategorie Name";
and add after ...
1
$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 ...
1
$lang['field_category_name'] = "Category name";
and add after ...
1
$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 ...  Very Happy

PS.
@  Acidgod ... dieser Topic kann nach Mods & Plugins verschoben werden ... Danke !
Logged

Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...
Acidgod
4images Moderator
4images Guru
*****
Offline Offline

Posts: 2420

Thank You
-Given: 0
-Receive: 1

It's me?


View Profile WWW
« Reply #7 on: January 31, 2007, 03:56:31 PM »

Gesagt getan... (o:
Logged

Tiburon
Jr. Member
**
Offline Offline

Posts: 85

Thank You
-Given: 14
-Receive: 2


View Profile WWW
« Reply #8 on: March 16, 2007, 10:53:16 AM »

hm, it does not work in 1.7.4  Crying or Very sad
Logged

----------------------------------

Have a nice Day
mawenzi
Moderator
4images Guru
*****
Offline Offline

Posts: 4500

Thank You
-Given: 36
-Receive: 119


View Profile
« Reply #9 on: March 16, 2007, 11:21:26 AM »

... tested also on a version 1.7.4 ... and it works great ... Wink
Logged

Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...
Jenn
Full Member
***
Offline Offline

Posts: 105

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #10 on: March 16, 2007, 03:25:58 PM »

Worked Beautifully on 1.7.4 as well Smile

Thanks for this. Helps out alot.
Logged
4ella
Jr. Member
**
Offline Offline

Posts: 90

Thank You
-Given: 0
-Receive: 0


View Profile WWW
« Reply #11 on: June 01, 2009, 01:54:31 PM »

Great modification , works good in 1.7.6 too
Logged


http://www.dancersrecruit.com/pictures/
4IMAGES 1.7.6 version/default theme
Apache version   2.2.11 (Unix)
PHP version   5.2.9
MySQL version   5.0.75-community-log
Architecture   x86_64
Operating system   Linux
truecolor
Pre-Newbie

Offline Offline

Posts: 1

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #12 on: June 04, 2009, 03:25:12 AM »

simulation credit auto
This worked really well. Many thanks  Cool
Logged
khansahib
Full Member
***
Offline Offline

Posts: 100

Thank You
-Given: 14
-Receive: 2


View Profile
« Reply #13 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 Smile
Logged
Bodzio
Newbie
*
Offline Offline

Posts: 35

Thank You
-Given: 0
-Receive: 0

BJ Fan


View Profile WWW
« Reply #14 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?
Logged

---
Best regards / Pozdrawiam serdecznie

Artur "Bodzio" Bogdański
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.173 seconds with 20 queries.
Post your comments here