Trick: New category in a few places of tree categories

Hello



Sometimes it is necessary to add a new category in the category tree a few places.

It is quite time-consuming if the category is a lot. This simple modification allows you to add a new category in many places in the category tree.

You need to modify two files.

controllers/customer/categories.php





```php //

// Create/update category

//

if ($mode == 'update') {

if(is_array($_REQUEST['category_data']['parent_id'])) {

foreach ($_REQUEST['category_data']['parent_id'] as $key => $value) {

if($value == 0) continue;

$data = $_REQUEST['category_data'];

$data['parent_id'] = $value;

$category_id = fn_update_category($data, $_REQUEST['category_id'], DESCR_SL);

$suffix = '.manage';

}

} else {

$category_id = fn_update_category($_REQUEST['category_data'], $_REQUEST['category_id'], DESCR_SL);



if (!empty($category_id)) {

fn_attach_image_pairs('category_main', 'category', $category_id, DESCR_SL);



$suffix = “.update?category_id=$category_id” . (!empty($_REQUEST['category_data']['block_id']) ? “&selected_block_id=” . $_REQUEST['category_data']['block_id'] : “”);

} else {

$suffix = '.manage';

}

}

}

```



admin/view/categories/update.tpl



[html] {if $smarty.request.dispatch == 'categories.add'}

{section name=cats start=1 loop=10 step=1}


{if "categories"|fn_show_picker:$smarty.const.CATEGORY_THRESHOLD}
{$lang.location}:
{include file="pickers/categories_picker.tpl" data_id="location_category" input_name="category_data[parent_id][`$smarty.section.cats.index`]" item_ids=$category_data.parent_id|default:"0" hide_link=true hide_delete_button=true show_root=true default_name=$lang.root_level display_input_id="location_category_id" except_id=$id}
{else}
{$lang.location}:

- {$lang.root_level} -
{foreach from=0|fn_get_plain_categories_tree:false item="cat" name="categories"}

{if $cat.id_path|strpos:"`$category_data.id_path`/" === false && $cat.category_id != $id || !$id}
{$cat.category|indent:$cat.level:"¦    ":"¦-- "}
{/if}


{/foreach}

{/if}

{/section}
{else}

{if "categories"|fn_show_picker:$smarty.const.CATEGORY_THRESHOLD}
{$lang.location}:
{include file="pickers/categories_picker.tpl" data_id="location_category" input_name="category_data[parent_id]" item_ids=$category_data.parent_id|default:"0" hide_link=true hide_delete_button=true show_root=true default_name=$lang.root_level display_input_id="location_category_id" except_id=$id}
{else}
{$lang.location}:

- {$lang.root_level} -
{foreach from=0|fn_get_plain_categories_tree:false item="cat" name="categories"}

{if $cat.id_path|strpos:"`$category_data.id_path`/" === false && $cat.category_id != $id || !$id}
{$cat.category|indent:$cat.level:"¦    ":"¦-- "}
{/if}


{/foreach}

{/if}

{/if}
[/html]


[img]http://demo150.cscart.com.pl/cat.png[/img]

I hope it's useful for someone. If you have questions please contact us.
Robert.

cats.tgz

Thank you for this post. For which version of CS-Cart dit you make this modification? I've checked with the latest version of CS-Cart ultimate and it doesn't seem to work.

It isn't Ultimate (nor V3 Professional), note the missing Store field between Categories and Full Description.

Hello.

This trick works on all versions of CS-Cart. Please contact me on priv, we will try to help you start the modification.



Regards

Robert