4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started 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 ===========
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)
-
hi,
where do i have tto add this code? do i need to replace anything? thanks
-
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:
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:
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 !!!
-
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 :)
-
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 ;)
-
@ 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 ...
-
... 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 ...
show_input_row($lang['field_category_name'], "cat_name", "", $textinput_size);
and replace with ...
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 ...
$lang['field_category_name'] = "Kategorie Name";
and add after ...
$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 ...
$lang['field_category_name'] = "Category name";
and add after ...
$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 !
-
Gesagt getan... (o:
-
hm, it does not work in 1.7.4 :cry:
-
... tested also on a version 1.7.4 ... and it works great ... ;)
-
Worked Beautifully on 1.7.4 as well :)
Thanks for this. Helps out alot.
-
Great modification , works good in 1.7.6 too
-
simulation credit auto (http://simulationcreditauto.net/)
This worked really well. Many thanks 8)
-
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 :)
-
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?