28d 2018, Navbar Categories

Open to all! Ask other shopowners for help.
User avatar
mhsuffolk
Contributor
Posts: 199
Joined: Sat Oct 26, 2019 9:13 am
Phoenix Version: v1.1.0.6
Has thanked: 13 times
Been thanked: 11 times

28d 2018, Navbar Categories

Post 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.


Join The Code Co-op to get access to your library in the Code Co-op Forum
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: 28d 2018, Navbar Categories

Post 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.
User avatar
mhsuffolk
Contributor
Posts: 199
Joined: Sat Oct 26, 2019 9:13 am
Phoenix Version: v1.1.0.6
Has thanked: 13 times
Been thanked: 11 times

Re: 28d 2018, Navbar Categories

Post by mhsuffolk »

No rush, I will have a try later.
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: 28d 2018, Navbar Categories

Post 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.
User avatar
mhsuffolk
Contributor
Posts: 199
Joined: Sat Oct 26, 2019 9:13 am
Phoenix Version: v1.1.0.6
Has thanked: 13 times
Been thanked: 11 times

Re: 28d 2018, Navbar Categories

Post 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.
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: 28d 2018, Navbar Categories

Post 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
User avatar
mhsuffolk
Contributor
Posts: 199
Joined: Sat Oct 26, 2019 9:13 am
Phoenix Version: v1.1.0.6
Has thanked: 13 times
Been thanked: 11 times

Re: 28d 2018, Navbar Categories

Post 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
You do not have the required permissions to view the files attached to this post.
LeeFoster
Contributor
Posts: 263
Joined: Sun Feb 28, 2021 9:41 pm
Phoenix Version: v1.0.8.20
Has thanked: 1 time
Been thanked: 5 times

Re: 28d 2018, Navbar Categories

Post by LeeFoster »

@mhsuffolk did you ever get this working? About to start looking at it for my 1.0.8.15 store.
User avatar
mhsuffolk
Contributor
Posts: 199
Joined: Sat Oct 26, 2019 9:13 am
Phoenix Version: v1.1.0.6
Has thanked: 13 times
Been thanked: 11 times

Re: 28d 2018, Navbar Categories

Post by mhsuffolk »

Yes I have it working. I am out at the moment, I will message you later.
User avatar
mhsuffolk
Contributor
Posts: 199
Joined: Sat Oct 26, 2019 9:13 am
Phoenix Version: v1.1.0.6
Has thanked: 13 times
Been thanked: 11 times

Re: 28d 2018, Navbar Categories

Post 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
You do not have the required permissions to view the files attached to this post.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply