if i use the standard breadcrumbs everything works fine.
i use the Omega Theme Omega 7.x-3.1. If I disable the breadcrumbs in the "Toggle advanced elements" the breadcrumbs block is available as block that I can move to different regions. But then the path breadcrumbs don't work anymore.

Comments

Elijah Lynn’s picture

I don't think they will work together, Delta uses a different template for breadcrumbs.

ruthverena75’s picture

i tried different ways to move the breadcrumbs to a own block and use the path breadcrumbs inside, but didn't succeed. i would be very happy if anybody would have a solution for this. meanwhile i trick it with absolute positioning with css.

Spleshka’s picture

Just use this snippet in your custom block:


$data = array(
  '#theme' => 'breadcrumb',
  '#breadcrumb' => drupal_get_breadcrumb(),
);

return render($data);

Spleshka’s picture

Status: Active » Closed (fixed)

Closing this issue. Please, feel free to reopen it if you have any questions.

anniegreens’s picture

Status: Closed (fixed) » Active

I cannot get path breadcrumbs to output anywhere but in the default theme placed location.

After trying to use the Delta block without success, and finding this issue queue, I added a block with the exact code provided above in a custom module with other hook-related overrides whose module weight is higher than path_breadcrumbs. The result is the same -- the default non-path_breadcrumb-provided breadcrumbs, basically just 'Home'.

Your hook_page_alter(), running drupal_set_breadcrumb, is running after my hook_block() that is running drupal_get_breadcrumb. Is there something else I'm missing here?

anniegreens’s picture

Status: Active » Fixed

After a bit of debugging I was able to get the code to work in a hook_preprocess_block function. Basically, to get the breadcrumbs placed specifically in certain regions on certain pages, context is needed for placing the block. The block content is then overridden in the preprocess function after the hook_page_alter where the path_breadcrumb is set. Hope this helps someone else that comes to find this thread.

/**
 * Implements hook_preprocess_block();
 */
function HOOK_preprocess_block(&$vars) {
  if ($vars['elements']['#block']->module == 'HOOK' && $vars['elements']['#block']->delta == 'breadcrumbs_block') {
    $data = array(
      '#theme' => 'breadcrumb',
      '#breadcrumb' => drupal_get_breadcrumb(),
    );
    $breadcrumb = render($data);
    $vars['content'] = $breadcrumb;
  }
}

Status: Active » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

twigley’s picture

Status: Closed (fixed) » Active

Hi anniegreens,

I'm having exactly the same issue, not being able to move breadcrumbs, but don't seem to be able to fix it by using the above.
I've tried adding the above code to a preprocess file, but it doesnt seem to make any difference.

Could you give a bit more detail?

Would really appreciate it.

Cheers

anniegreens’s picture

Hi twigley,

I'm placing my breadcrumbs as a block with the context module to get it to show up exactly where and when I want. I'm also using the Delta blocks version of breadcrumbs as a block. None of that should really matter. You can accomplish the same thing by creating a breadcrumb block in your own custom module.

The key here is that drupal_get_breadcrumb will run before path_breadcrumbs' hook_page_alter where the magic happens. Since path_breadcrumbs is using the actual page path to set the breadcrumb, the path of the page must be known before altering the breadcrumbs. So in order for us to capture the altered breadcrumbs, we need to grab the breadcrumbs after the fact. Enter the hook_preprocess_block function, which will run after the hook_page_alter.

I've placed the above code in my theme preprocess-block.inc file (Omega sub-theme) but you may need to place it in your theme template.php file. Replace the first HOOK in hook_preprocess_block with the name of your theme. Replace the second HOOK in the IF statement with the name of the module that implements your block -- in my case 'delta_blocks'. Finally, replace the 'breadcrumbs_block' with the delta (or machine name) of the block you are overriding -- in my case it was simply 'breadcrumb'. You can get the name of the delta of the block by hovering over the 'configure' link for the block on the blocks UI admin page. Where /admin/structure/block/manage/[module_name]/[block_delta_name]/configure is the path, [module_name] is the name of the module providing the block and [delta_block_name] is the delta of the block. You can also use the devel module to output the $vars inside your preprocess function and get the same information.

Hope that helps.

twigley’s picture

Hi anniegreens,

Thanks for the update and the detailed description.
Unfortunately I'm still struggling with this.

Here's my current situation. I'm using Omega theme and have created my own sub-theme called clomega.
I have path breadcrumbs setup and working on a number of different types of pages. These are working fine and showing in the default position at the top of the content section, beneath the header.
I also have the delta blocks module installed and am using this to display breadcrumbs within a block called breadcrumb (default I think), which I have placed in the area I want to actually show the path breadcrumbs.

/**
 * Implements hook_preprocess_block();
 */
function clomega_preprocess_block(&$vars) {
  if ($vars['elements']['#block']->module == 'delta_blocks' && ['#block']->delta == 'breadcrumb') {
    $data = array(
      '#theme' => 'breadcrumb',
      '#breadcrumb' => drupal_get_breadcrumb(),
    );
    $breadcrumb = render($data);
    $vars['content'] = $breadcrumb;
  }
  

I've made the amendments to the code block you provided as above, with clomega instead of HOOK in the function name, the module as delta_blocks and using the breadcrumbs block as 'breadcrumb'.

I've added this code to a file called preprocess-block.inc and put this into the clomega/preprocess folder. When I do this and refresh the page, the code from above is actually displayed over the header of the website and doesn't appear to be being processed.

When I add this code to the template.php file and upload this nothing changes.

Any idea where I'm going wrong?
Really appreciate your ongoing help.

anniegreens’s picture

Status: Fixed » Active

twigley,

Two things:

  1. Add 'alpha' to your hook_preprocess_block function. Alpha is the base theme of Omega, so your function name should be clomega_alpha_preprocess_block.
  2. It looks like I missed the closing } when I copied and pasted my code above (I have just fixed it) and yours appears to be suffering from the same.

Hopefully these two items do the trick!

Begun’s picture

@twigley

There are some other possible issues with your code:

  1. Make sure your code is contained in a <?php code block. The absence of this could be why the code is printing to screen.
  2. ['#block']->delta is not a valid variable name. Try changing it to $vars['block']->delta or $vars['#elements']['block']->delta. Both seem to point to the same object so I assume they are both valid variable references.

This is what my preprocess-block.inc file looks like:



/**
 * Implements hook_alpha_preprocess_block()
 *
 * There is an issue with using Path Breadcrumb module with Delta blocks.  
 * See drupal.org/node/1777644 for description of issue and fix.
 */
function nabto_alpha_preprocess_block(&$vars) {
  if ($vars['block']->module == 'delta_blocks' && $vars['block']->delta == 'breadcrumb') {
    $data = array(
      '#theme' => 'breadcrumb',
      '#breadcrumb' => drupal_get_breadcrumb(),
    );
    $breadcrumb = render($data);
    $vars['content'] = $breadcrumb;
  }
}
anniegreens’s picture

Good catch Begun.

Yes, twigley, you are missing the $vars['elements'] part of the second check in your if statement. It should be $vars['elements']['#block']->delta == 'breadcrumb'

samwillc’s picture

Hi,

I'm having a similar problem in that the delimiter does not show up. I also use delta and context to place the breadcrumb block on the page.

I have tried the above code in template.php and in preprocess-block.inc file which I created and put in the preprocess folder in my subtheme. It still doesn't seem to work. This is the code from default/themes/custom_theme/preprocess/preprocess-block.inc:

<?php

/**
* Implements hook_alpha_preprocess_block()
*
* There is an issue with using Path Breadcrumb module with Delta blocks. 
* See drupal.org/node/1777644 for description of issue and fix.
*/
function custom_theme_alpha_preprocess_block(&$vars) {
  if ($vars['block']->module == 'delta_blocks' && $vars['#elements']['block']->delta == 'breadcrumb') {
    $data = array(
      '#theme' => 'breadcrumb',
      '#breadcrumb' => drupal_get_breadcrumb(),
    );
    $breadcrumb = render($data);
    $vars['content'] = $breadcrumb;
  }
}
?>

Not sure if I'm doing something wrong here but the custom breadcrumbs module worked perfectly for me before, will have to go back to that in the meantime.

Any help is very much appreciated, thanks.

samwillc’s picture

Sorry, me again. Works perfectly, WITH delimiter, and replaces the default breadcrumb block sitewide. Here's the code:

<?php

/**
* Implements hook_alpha_preprocess_block()
*
* There is an issue with using Path Breadcrumb module with Delta blocks. 
* See drupal.org/node/1777644 for description of issue and fix.
*/
function custom_theme_alpha_preprocess_block(&$vars) {
  if ($vars['block']->module == 'delta_blocks' && $vars['block']->delta == 'breadcrumb') {
    $data = array(
      '#theme' => 'breadcrumb',
      '#breadcrumb' => drupal_get_breadcrumb(),
    );
    $breadcrumb = render($data);
    $vars['content'] = $breadcrumb;
  }
}
?>

$vars['#elements']['block'] did not work for me. I didn't have to put this in template.php either. Just chucked the 'preprocess-block.inc' file in my preprocess folder and flushed caches.

Thanks people :)