*

vansebas

  • ***
  • 35 posts
Breadcrumb showing only one category and no main categories
« on: February 26, 2021, 09:24:04 PM »
In my OS class I have created some main categories and under those main categories I created subcategories.
Now when I go to the listing item page I see the breadcrumb who look like this:
Sitename > Subcategory > Listing name

The category is the subcategory the listing falls under.
Why isn't the main category also listed in the breadcrumbs? So you would get:
Sitename > Main category > Subcategory > Listing name

*

MB Themes

Re: Breadcrumb showing only one category and no main categories
« Reply #1 on: February 26, 2021, 09:57:07 PM »
@vansebas
Breadcrumbs does not show all possible information, just primary ones.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Marked as best answer by vansebas on February 27, 2021, 09:58:36 AM
*

vansebas

  • ***
  • 35 posts
Re: Breadcrumb showing only one category and no main categories
« Reply #2 on: February 27, 2021, 09:58:13 AM »
I solved the issue with a edit of the Breadcrumb.php file in the folder "oc-includes\osclass\classes".
On row57 "underneath the tag: case('item')" this was the original code
Code: [Select]
        try {
        $aCategory = osc_get_category( 'id' , osc_item_category_id() );
        } catch ( Exception $e ) {
        }
        // remove
        View::newInstance()->_erase('categories');
        View::newInstance()->_erase('subcategories');
        View::newInstance()->_exportVariableToView('category', $aCategory);

        try {
        $l = array (
          'url'   => osc_search_category_url() ,
          'title' => osc_category_name()
        );
        } catch ( Exception $e ) {
        }
        $this->addLevel($l);


And I changed it to:
Code: [Select]
        try {
        $aCategory = osc_get_category( 'id' , osc_item_category_id() );
$parentCategory = osc_get_category('id', $aCategory['fk_i_parent_id']);
        } catch ( Exception $e ) {
        }
        // remove
        View::newInstance()->_erase('categories');
        View::newInstance()->_erase('subcategories');
        View::newInstance()->_exportVariableToView('category', $parentCategory);

        try {
        $l = array (
          'url'   => osc_search_category_url() ,
          'title' => osc_category_name()
        );
        } catch ( Exception $e ) {
        }
        $this->addLevel($l);

View::newInstance()->_exportVariableToView('category', $aCategory);
try {
        $l = array(
          'url'   => osc_search_category_url(),
          'title' => osc_category_name()
        );
} catch ( Exception $e ) {
        }
        $this->addLevel($l);

And now I see on the listing page the following breadcrumb path:
Sitename > Main category > Subcategory > Listing title

So if somebody else has the same problem this would solve it!

@OSclass builders; maybe a good add-on in a future release of the software?

*

MB Themes

Re: Breadcrumb showing only one category and no main categories
« Reply #3 on: February 27, 2021, 10:09:51 AM »
@vansebas
Thanks for nice tip ;)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: Breadcrumb showing only one category and no main categories
« Reply #4 on: March 04, 2021, 02:00:56 PM »
Thanks, this worked like a charm