Hello
Here is a simple trick that allows you to show the full path to the category when editing product. This can be useful if you have a complicated and large tree category.
First add function to file func.php in directory /addons/my_changes
```php
function fn_my_changes_get_path_category($category_id) {
$id_path = db_get_field(“SELECT id_path FROM ?:categories WHERE category_id=”.$category_id);
$path = preg_split(“///”,$id_path);
$category_desc = '';
foreach ($path as $path_key => $path_value) {
$temps = db_get_field(“SELECT category FROM ?:category_descriptions WHERE category_id=”.$path_value." AND lang_code='PL'“);
$category_desc .= $temps.”/“;
} // end foreach
$category_desc = preg_replace(”//$/“,”",$category_desc);
return $category_desc;
} // end method fn_my_changes_get_path_category
```
Second
In file /skins/basic/admin/pickers/js_category.tpl change code
[html] {assign var=“default_category” value=“$ldelim
category$rdelim
”}
{assign var=“default_category_id” value=“$ldelim
category_id$rdelim
”}
{if $first_item || !$category_id}{if $hide_input != “Y”}{/if}{$default_category}
{/if}
{if $category_id}{$category_id}" {$extra}>{if $hide_input != “Y”} {/if}
{/if}
[/html]
change on
[html] {assign var=“default_category” value=“$ldelim
category$rdelim
”}
{assign var=“default_category_id” value=“$ldelim
category_id$rdelim
”}
{assign var=“path_category” value=$category_id|fn_my_changes_get_path_category}
{if $first_item || !$category_id}{if $hide_input != “Y”}{/if}{$default_category}
{/if}
{if $category_id}{$category_id}" {$extra}>{if $hide_input != “Y”} {/if}
{/if}
[/html]
Below effect:
Regards
Robert Diak
Hello.
The following correction function, because when you add the product generated mistake.
```php
function fn_my_changes_get_path_category($category_id) {
if(!empty($category_id)) {
$id_path = db_get_field(“SELECT id_path FROM ?:categories WHERE category_id=”.$category_id);
$path = preg_split(“///”,$id_path);
$category_desc = '';
foreach ($path as $path_key => $path_value) {
if(!empty($path_value)) {
$temps = db_get_field(“SELECT category FROM ?:category_descriptions WHERE category_id=”.$path_value." AND lang_code='PL'“);
$category_desc .= $temps.”/“;
} // end if
} // end foreach
$category_desc = preg_replace(”//$/“,”",$category_desc);
return $category_desc;
} // end if
} // end method fn_my_changes_get_path_category
```
Regards.
Robert Diak
Hello.
The following correction function, because when you add the product generated mistake.
```php
function fn_my_changes_get_path_category($category_id) {
if(!empty($category_id)) {
$id_path = db_get_field(“SELECT id_path FROM ?:categories WHERE category_id=”.$category_id);
$path = preg_split(“///”,$id_path);
$category_desc = '';
foreach ($path as $path_key => $path_value) {
if(!empty($path_value)) {
$temps = db_get_field(“SELECT category FROM ?:category_descriptions WHERE category_id=”.$path_value." AND lang_code='“.CART_LANGUAGE.”'“);
$category_desc .= $temps.”/“;
} // end if
} // end foreach
$category_desc = preg_replace(”//$/“,”",$category_desc);
return $category_desc;
} // end if
} // end method fn_my_changes_get_path_category
```
Regards
Robert Diak
Very useful trick, it should be added into cs-cart by default
—
Valentin
After applying this change:
On Save of product, I get a page with “continue”, hyperlinked to dispatch=products.update. After approx 10 seconds the process continues as normal.
This is new - I never had this delay w/continue page on a product update before. Is this normal behavior?
It appears to be caused after I created func.php in the addon/my_changes folder.
This is the entire contents of func.php:
```php
if ( !defined('AREA') ) { die('Access denied'); }
function fn_my_changes_get_path_category($category_id)
{
if(!empty($category_id))
{
$id_path = db_get_field("SELECT id_path FROM ?:categories WHERE category_id=".$category_id);
$path = preg_split("/\//",$id_path);
$category_desc = '';
foreach ($path as $path_key => $path_value)
{
if(!empty($path_value))
{
$temps = db_get_field("SELECT category FROM ?:category_descriptions WHERE category_id=".$path_value." AND lang_code='".CART_LANGUAGE."'");
$category_desc .= $temps."/";
} // end if
} // end foreach
$category_desc = preg_replace("/\/$/","",$category_desc);
return $category_desc;
} // end if
} // end method fn_my_changes_get_path_category
?>
```
Hello
If you can send me an ftp access and the panel, we will check it.
This should not be happening.
Regards
Robert Diak
@Magpie Don
please check in the file addon/my_changes/func.php after ?>
you have blank line/s, this is the reason why continue message appear, delete all the blank line, and check also other modified php files
—
Valentin
Hello.
Yes Vali's right. The cause can be any white space in the file func.php
Regards
Robert Diak.
Yes, thank you. That was the cause. My mistake.
Very useful modification since CS-Cart store now shows products in sub-categories.
What we need is to move the “Search in Sub-categories” checkbox out of the Admin's advanced search form and into the main search form.
Hello.
Do you know how we can do this trick in version 4?
Hi @sertaconay
For cs-cart 4 you need to follow steps bellow:[list=1]
[]copy to file [color=#008000]app/addons/my_changes/func.php[/color]
/*****************************************************************
* *
* (c) 2013 HungryWeb.net | Support at Yum [at] hungryweb.net *
* *
*****************************************************************/
if (!defined('BOOTSTRAP')) { die('Access denied'); } function fn_my_changes_get_path_category($category_id) {
if(!empty($category_id)) {
$id_path = db_get_field("SELECT id_path FROM ?:categories WHERE category_id=".$category_id);
$path = preg_split("/\//",$id_path);
$category_desc = '';
foreach ($path as $path_key => $path_value) {
if(!empty($path_value)) {
$temps = db_get_field("SELECT category FROM ?:category_descriptions WHERE category_id=".$path_value." AND lang_code='".CART_LANGUAGE."'");
$category_desc .= $temps." / ";
} // end if
} // end foreach
$category_desc = preg_replace("/ \/ $/","",$category_desc);
return $category_desc;
} // end if
} // end method fn_my_changes_get_path_category
[ ]on file [color=#008000]design/backend/templates/pickers/categories/js.tpl[/color]
[/list]
after:
{assign var="default_category" value="`$ldelim`category`$rdelim`"}
{assign var="default_category_id" value="`$ldelim`category_id`$rdelim`"}
add:
{** add by hungryweb.net **}
{assign var="default_category" value=$category_id|fn_my_changes_get_path_category}
{assign var="category" value=$default_category}
[ Tested on CS-Cart: version 4.0.1 ULTIMATE ]
I hope that helps,
—
Valentin