Show Breadcrumb in the content place instead of header

Open to all! Ask other shopowners for help.
loop
Contributor
Posts: 253
Joined: Thu Mar 25, 2021 12:26 pm
Phoenix Version:
Has thanked: 7 times
Been thanked: 3 times

Show Breadcrumb in the content place instead of header

Post by loop »

Hi all
I'm trying to display the breadcrumb in the middle (where the content is) and not on top (over Navigation)

Of course I could make a new module for PI so it works in products_info.php but then I would have to make a new module for the "index.php" that makes no sense to make the module multiple times. Is there a way to have it like the header module, but show it in content place?

Thank you!
Philipp


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: Show Breadcrumb in the content place instead of header

Post by ecartz »

Code: Select all

        <?= $hooks->cat('injectBodyContentStart') ?>
So perhaps something like

Code: Select all

class hook_shop_siteWide_breadcrumb {

  const EXCLUDES = [];

  public function listen_injectBodyContentStart() {
    if (!in_array(Request::get_page(), static::EXCLUDES)) {
      include $GLOBALS['Template']->map(DIR_FS_CATALOG . 'includes/modules/content/header/cm_header_breadcrumb.php');
    }
  }
}
The content module LOCATION would then have to be set to Schema so that it doesn't show twice. Or duplicate or override the module if you don't want the schema.
loop
Contributor
Posts: 253
Joined: Thu Mar 25, 2021 12:26 pm
Phoenix Version:
Has thanked: 7 times
Been thanked: 3 times

Re: Show Breadcrumb in the content place instead of header

Post by loop »

thank you ecartz!

Code: Select all

class hook_shop_siteWide_breadcrump_position {

const EXCLUDES = [];

    public function listen_injectBodyContentStart() {
     if (!in_array(Request::get_page(), static::EXCLUDES)) {
            $tpl_data = [
                'group' => 'header',
                'file' => DIR_FS_CATALOG . 'includes/modules/header/cm_header_breadcrumb.php',
            ];
            include 'includes/modules/content/cm_template.php';
        } 
    }
}
i get no error, but also don't show the breadcrump in the middle, wenn i put echo "test" in the hook, it shows perfectly in the place i need, but not the content of the header module. Any ideas?
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Show Breadcrumb in the content place instead of header

Post by ecartz »

It looks like I had the path wrong. I updated it.
loop
Contributor
Posts: 253
Joined: Thu Mar 25, 2021 12:26 pm
Phoenix Version:
Has thanked: 7 times
Been thanked: 3 times

Re: Show Breadcrumb in the content place instead of header

Post by loop »

still no output, maybe the "include" does not work in the hook? maybe needs a echo or return?

while investigating, whats in the : include 'includes/modules/content/cm_template.php';
i found out, if i REMOVE ob_get_clean() it works...hmm
so if i make this, i have the output as it should....do you know the reason? should i leave it like this or do you have a solution?

Code: Select all

            $tpl_data = [
                'group' => 'header',
                'file' => DIR_FS_CATALOG . 'includes/modules/content/header/cm_header_breadcrumb.php',
            ];
            //include 'includes/modules/content/cm_template.php';
            ob_start();
            include($GLOBALS['oscTemplate']->map_to_template($tpl_data['file']));
            $GLOBALS['oscTemplate']->addContent('', $tpl_data['group']);
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Show Breadcrumb in the content place instead of header

Post by ecartz »

Just change that whole section of code that you posted to

Code: Select all

include $GLOBALS['Template']->map(DIR_FS_CATALOG . 'includes/modules/content/header/cm_header_breadcrumb.php');
loop
Contributor
Posts: 253
Joined: Thu Mar 25, 2021 12:26 pm
Phoenix Version:
Has thanked: 7 times
Been thanked: 3 times

Re: Show Breadcrumb in the content place instead of header

Post by loop »

Perfect, it works! thank you!
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Re: Show Breadcrumb in the content place instead of header

Post by lecarlb »

@ecartz I would like to move the breadcrumb just below the header or same place as original poster.

I see that you gave code changes but it's confusing. Could you kindly tell what code and in what file that needs to be changed?

Thank you.
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Show Breadcrumb in the content place instead of header

Post by burt »

There is an example of a Hooked breadcrumb in the S05E06 Supporters Code;

/templates/gustavo/includes/hooks/shop/siteWide/breadCrumb.php
I am not here to build for you.
I am here to build with you. Let's help each other.
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Show Breadcrumb in the content place instead of header

Post by ecartz »

lecarlb wrote: Wed Aug 03, 2022 8:07 am @ecartz I would like to move the breadcrumb just below the header or same place as original poster.

I see that you gave code changes but it's confusing. Could you kindly tell what code and in what file that needs to be changed?
Create

Code: Select all

class hook_shop_siteWide_breadcrumb {

  const EXCLUDES = [];

  public function listen_injectBodyContentStart() {
    if (!in_array(Request::get_page(), static::EXCLUDES)) {
      include $GLOBALS['Template']->map(DIR_FS_CATALOG . 'includes/modules/content/header/cm_header_breadcrumb.php');
    }
  }
}
in a file includes/hooks/shop/siteWide/breadcrumb.php -- you should also be able to put it in the hooks directory in a template. As shown, this will show on every page. You can put pages for it not to show in the EXCLUDES array.

Don't forget to turn the regular module on but set to SCHEMA. If you don't want the schema, then Burt's approach is probably better. Burt's example also doesn't show on the front page but does show on category/product listing pages.


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