Page 1 of 2

28d 2018, Navbar Categories

Posted: Tue Apr 12, 2022 4:47 pm
by mhsuffolk
Working my way up the versions, now attempting 1.0.7.13
I have a very early supporters code from @burt which is a Navbar categories module.
It throws this error.
Fatal error: Uncaught Error: Call to undefined method category_tree::setCategoryPath() in D:\Phoenix_Live\htdocs\includes\modules\navbar\nb_navbar_categories.php:53 Stack trace: #0 D:\Phoenix_Live\htdocs\includes\modules\content\navigation\cm_navbar.php(60): nb_navbar_categories->getOutput() #1 D:\Phoenix_Live\htdocs\includes\system\versioned\1.0.7.9\osc_template.php(106): cm_navbar->execute() #2 D:\Phoenix_Live\htdocs\templates\default\includes\components\template_top.php(46): oscTemplate->getContent('navigation') #3 D:\Phoenix_Live\htdocs\templates\default\includes\pages\index.php(13): require('D:\\Phoenix_Live...') #4 D:\Phoenix_Live\htdocs\index.php(17): require('D:\\Phoenix_Live...') #5 {main} thrown in D:\Phoenix_Live\htdocs\includes\modules\navbar\nb_navbar_categories.php on line 53

The code around Line 53 is

Code: Select all

    function getOutput() {
      global $oscTemplate;
      
      $NB_CategoryTree = new category_tree();
      $NB_CategoryTree->setCategoryPath($cPath, '<strong>', '</strong>');
      $NB_CategoryTree->setMaximumLevel(1);
      $NB_CategoryTree->setParentGroupString('<ul class="dropdown-menu">', '</ul>', true);
      $NB_category_tree = $NB_CategoryTree->getTree();
      
      ob_start();
      require('includes/modules/navbar/templates/tpl_' . basename(__FILE__));
      $data = ob_get_clean();
@ecartz, when I asked about this addon many months ago, I believe you said that you did not have this. I can PM it to you if you can help.

Re: 28d 2018, Navbar Categories

Posted: Tue Apr 12, 2022 5:08 pm
by ecartz
I'm not going to be able to look at it for a few hours, as I have something to do now.

Usually when there are category_tree issues, they're caused from when I moved some of the methods from category_tree to tree_display.

Note that some of the methods would be defined in displayable_tree_accessor.

List of files using tree_display: https://github.com/CE-PhoenixCart/Phoen ... ee_display

E.g. https://github.com/CE-PhoenixCart/Phoen ... isting.php

Relevant commit: https://github.com/CE-PhoenixCart/Phoen ... 6c286b07e8

Perhaps try to modify the code you have as that code was modified?

In general, if a method isn't in tree or category_tree but is in tree_display or displayable_tree_accessor, you should move it to a tree_display object. Some methods may have changed names as well.

Re: 28d 2018, Navbar Categories

Posted: Tue Apr 12, 2022 5:23 pm
by mhsuffolk
No rush, I will have a try later.

Re: 28d 2018, Navbar Categories

Posted: Tue Apr 12, 2022 6:37 pm
by ecartz

Code: Select all

      $display = new tree_display(new category_tree());
      $display->setPath($cPath, '<strong>', '</strong>');
      $display->setMaximumLevel(1);
      $display->setParentGroupString('<ul class="dropdown-menu">', '</ul>', true);
      $NB_category_tree = "$display";
I think that this is the new equivalent of the five lines ending with the $NB_category_tree assignment.

I'm not sure that it's necessary to create a new category_tree object here, but I kept it since I'm not sure of the consequences.

Re: 28d 2018, Navbar Categories

Posted: Wed Apr 13, 2022 5:00 pm
by mhsuffolk
Thank you @ecartz, that works perfectly.
As this is a long lost genuine @burt supporters code would you like me to PM the code to you for possibly adding to PRO. IMO it is a very useful addition to a shop in that the categories side box can be removed.

Re: 28d 2018, Navbar Categories

Posted: Wed Apr 13, 2022 6:52 pm
by ecartz
If Burt wants to add it to Pro, he could. I'm not clear on how it differs from viewtopic.php?f=28&t=246

Re: 28d 2018, Navbar Categories

Posted: Thu Apr 14, 2022 6:32 am
by mhsuffolk
ecartz wrote: Wed Apr 13, 2022 6:52 pm If Burt wants to add it to Pro, he could. I'm not clear on how it differs from viewtopic.php?f=28&t=246
This one, being a Navbar module, goes into the Hamburger on small screens which I like. The category box IMO is a nuisance on a phone display.
This Navbar module still gives the customer the option to view the categories
Capture.JPG
Capture 2.JPG

Re: 28d 2018, Navbar Categories

Posted: Fri Jun 10, 2022 8:51 am
by LeeFoster
@mhsuffolk did you ever get this working? About to start looking at it for my 1.0.8.15 store.

Re: 28d 2018, Navbar Categories

Posted: Fri Jun 10, 2022 9:11 am
by mhsuffolk
Yes I have it working. I am out at the moment, I will message you later.

Re: 28d 2018, Navbar Categories

Posted: Fri Jun 10, 2022 12:26 pm
by mhsuffolk
Following the advice from @ecartz(see above) this zip should work on 1.0.8.3 onwards. Tested on 1.0.8.15
Navbar Categories.zip