Page 1 of 1
Changing root category id
Posted: Tue May 09, 2023 7:42 am
by radhavallabh
Hi;
I am trying to make a category menu which takes the current category id as its root and displays its sub categories.
I duplicated the bm_categories.php module and tried assigning this to the global variable of $root_category_id
Code: Select all
$root_category_id= intval($GLOBALS['current_category_id']);
But still it does not change the root level of the category menu.
Can someone please help me achieve this;
Help shall be deeply appreciated dear;
Thank you in advance;
Warm Regds./
radhavallabh
Re: Changing root category id
Posted: Tue May 09, 2023 8:35 am
by ecartz
If you go back to the original code in the execute method, change
https://github.com/CE-PhoenixCart/Phoen ... es.php#L18 Code: Select all
$display = new tree_display(Guarantor::ensure_global('category_tree'));
to
Code: Select all
$category_tree = new category_tree();
$category_tree->set_root_id((int)$GLOBALS['current_category_id']);
$display = new tree_display($category_tree);
Re: Changing root category id
Posted: Tue May 09, 2023 8:48 am
by radhavallabh
ecartz wrote: ↑Tue May 09, 2023 8:35 am
If you go back to the original code in the execute method, change
https://github.com/CE-PhoenixCart/Phoen ... es.php#L18 Code: Select all
$display = new tree_display(Guarantor::ensure_global('category_tree'));
to
Code: Select all
$category_tree = new category_tree();
$category_tree->set_root_id((int)$GLOBALS['current_category_id']);
$display = new tree_display($category_tree);
Worked like a charm dear!! Thank you so much!
Re: Changing root category id
Posted: Tue May 09, 2023 9:18 am
by radhavallabh
ecartz wrote: ↑Tue May 09, 2023 8:35 am
If you go back to the original code in the execute method, change
https://github.com/CE-PhoenixCart/Phoen ... es.php#L18 Code: Select all
$display = new tree_display(Guarantor::ensure_global('category_tree'));
to
Code: Select all
$category_tree = new category_tree();
$category_tree->set_root_id((int)$GLOBALS['current_category_id']);
$display = new tree_display($category_tree);
Dear this helps change the root level of the category now
But it does not display the name of the category that has become the root itself now.
Like if root_category_id now becomes 25 instead of 0,
it shows the sub_categories example 25_34 , 25_36 under it, but does not display the name of root_category_id 25 itself also.
Any way to achieve that too??
Thank you in advance;
Very Warm Regds./
radhavallabh
Re: Changing root category id
Posted: Tue May 09, 2023 9:44 am
by ecartz
Edit the template to show the current category somewhere? E.g. at
https://github.com/CE-PhoenixCart/Phoen ... es.php#L18