Page 1 of 2

Show Breadcrumb in the content place instead of header

Posted: Thu Feb 03, 2022 10:49 am
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

Re: Show Breadcrumb in the content place instead of header

Posted: Thu Feb 03, 2022 11:09 am
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.

Re: Show Breadcrumb in the content place instead of header

Posted: Thu Feb 03, 2022 11:22 am
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?

Re: Show Breadcrumb in the content place instead of header

Posted: Thu Feb 03, 2022 11:37 am
by ecartz
It looks like I had the path wrong. I updated it.

Re: Show Breadcrumb in the content place instead of header

Posted: Thu Feb 03, 2022 12:14 pm
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']);

Re: Show Breadcrumb in the content place instead of header

Posted: Thu Feb 03, 2022 6:39 pm
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');

Re: Show Breadcrumb in the content place instead of header

Posted: Fri Feb 04, 2022 8:18 am
by loop
Perfect, it works! thank you!

Re: Show Breadcrumb in the content place instead of header

Posted: Wed Aug 03, 2022 8:07 am
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.

Re: Show Breadcrumb in the content place instead of header

Posted: Wed Aug 03, 2022 10:23 am
by burt
There is an example of a Hooked breadcrumb in the S05E06 Supporters Code;

/templates/gustavo/includes/hooks/shop/siteWide/breadCrumb.php

Re: Show Breadcrumb in the content place instead of header

Posted: Wed Aug 03, 2022 12:08 pm
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.