Advertisement:

Author Topic: Show parent category on breadcrumb  (Read 1381 times)

makmortifera

  • Newbie
  • *
  • Posts: 33
Show parent category on breadcrumb
« on: June 23, 2017, 07:33:21 pm »
Hello everyone, I do not know the name given to this, I call the path, but the path of my theme is not showing the parent category, that is, if someone enters the ad, it will be "lost".





Does anyone know how to display the parent category before the subcategory in the path??
« Last Edit: June 28, 2017, 11:55:08 pm by makmortifera »

gave

  • Newbie
  • *
  • Posts: 26
Re: Show parent category on path from item
« Reply #1 on: June 24, 2017, 12:40:03 pm »
- Do you have the Admin / General Settings / Parent category selectabel option on or off?
- Always helpful to say which theme you are using too (if the problem is on theme level).


makmortifera

  • Newbie
  • *
  • Posts: 33
Re: Show parent category on path from item
« Reply #2 on: June 26, 2017, 05:07:32 pm »
- Do you have the Admin / General Settings / Parent category selectabel option on or off?
- Always helpful to say which theme you are using too (if the problem is on theme level).

Hi gave, sorry, I forgot...

- (Parent category selectabel) - It is unchecked
- (Theme) - OsclassWizards

gave

  • Newbie
  • *
  • Posts: 26
Re: Show parent category on path from item
« Reply #3 on: June 26, 2017, 08:45:42 pm »
Unfortunately this does not seem to be a theme-level issue. The output function does not support this param.

Since you are on an item page, you can probably 'hack' this in by printing the current item's category in a HTML data-attrib and use that value to append into the link list with javascript.

I dont have access to an osclass site now to try this :S .

gave

  • Newbie
  • *
  • Posts: 26
Re: Show parent category on path from item
« Reply #4 on: June 27, 2017, 10:33:13 am »
So, I actually got to try this yesterday. I had another idea to move the breadcrumbs to each page from the header, and split + append the string in PHP, which would work alright if somehow the item's parent category could be retrieved. This is where I got stuck. I didnt find an easy/graceful way to retrieve the parent category.


makmortifera

  • Newbie
  • *
  • Posts: 33
Re: Show parent category on path from item
« Reply #5 on: June 27, 2017, 07:20:33 pm »
So, I actually got to try this yesterday. I had another idea to move the breadcrumbs to each page from the header, and split + append the string in PHP, which would work alright if somehow the item's parent category could be retrieved. This is where I got stuck. I didnt find an easy/graceful way to retrieve the parent category.

Thank you for the reply gave, i'll try to give another verified and try to find how to put this. I managed to put it in my home page, but I can not find where I change the code of this path.

makmortifera

  • Newbie
  • *
  • Posts: 33
Re: Show parent category on path from item
« Reply #6 on: June 28, 2017, 11:54:21 pm »
I found the code, but I have no idea what needs to change here. Anyone have an idea?

/oc-includes/osclass/classes/Breadcrumb.php

Code: [Select]
$node = array();
            for($i = 0; $i < count($this->aLevel); $i++) {
                $text = '<li ';
                // set a class style for first and last <li>
                if( $i == 0 ) {
                    $text .= 'class="first-child" ';
                }
                if( ($i == (count($this->aLevel) - 1)) && ($i != 0) ) {
                    $text .= 'class="last-child" ';
                }
                $text .='itemscope itemtype="http://data-vocabulary.org/Breadcrumb" >';
                // set separator
                if( $i > 0 ) {
                    $text .= ' ' . $separator . ' ';
                }
                // create span tag
                $title = '<span itemprop="title">' . $this->aLevel[$i]['title'] . '</span>';
                if( array_key_exists('url', $this->aLevel[$i]) ) {
                    $title = '<a href="' . osc_esc_html($this->aLevel[$i]['url']) . '" itemprop="url">' . $title . '</a>';
                }
                $node[] = $text . $title . '</li>' . PHP_EOL;
            }
« Last Edit: June 28, 2017, 11:56:14 pm by makmortifera »

makmortifera

  • Newbie
  • *
  • Posts: 33
Re: Show parent category on breadcrumb
« Reply #7 on: July 05, 2017, 03:48:52 pm »
Any new ideas?