I hope the answer would come in handy for other users, maybe it could become an episode for your screencast :)

I have a taxonomy browsing section with quite a simple 2-level URL scheme:

site.com/langcode/products/%manufacturer/
site.com/langcode/products/%manufacturer/%product

where manufacturer is a taxonomy term name (transliterated) and the product is a node title (transliterated). Both patterns are governed by Pathauto. So, for this path:
site.com/langcode/walt-disney/winnie-the-pooh
I should have breadcrumbs like:
[Home] > [Products] > [Walt Disney] > Winnie the Pooh

The product node "Winnie the Pooh" is an instance of a content type Product.
As much I could understand the PB philosophy, I created a definition like the one below, but could not get it to work when browsing through my products section. Any advice as per why, please?

How do I convert transliterated names from paths into human names needed for titles? (Currently I put identical values just to get anything).

$path_breadcrumb = new stdClass();
$path_breadcrumb->api_version = 1;
$path_breadcrumb->machine_name = 'producenci';
$path_breadcrumb->name = 'Producenci';
$path_breadcrumb->path = 'produkty/%manufacturer/%product';
$path_breadcrumb->data = array(
  'titles' => array(
    0 => '%manufacturer:name',
    1 => '%product:title',
  ),
  'paths' => array(
    0 => '%manufacturer:name',
    1 => '%product:title',
  ),
  'home' => 1,
  'translatable' => 1,
  'arguments' => array(
    'manufacturer' => array(
      'position' => 1,
      'argument' => 'term',
      'settings' => array(
        'identifier' => 'Taxonomy term: ID',
        'input_form' => 'term',
        'vids' => array(
          2 => '2',
          1 => 0,
        ),
        'breadcrumb' => 0,
        'transform' => 0,
      ),
    ),
    'product' => array(
      'position' => 2,
      'argument' => 'entity_id:node',
      'settings' => array(
        'identifier' => 'Node: ID',
      ),
    ),
  ),
  'access' => array(),
);
$path_breadcrumb->weight = 0;

Comments

moniuch’s picture

Issue summary: View changes

fixed code formatting

moniuch’s picture

Issue summary: View changes

fixed language

kalabro’s picture

  1. “Path Breadcrumbs” works with system paths, not aliases, so first, your path for node will be node/%product_node
  2. Yes, you are on the correct way to use arguments, but for our path node/%product_node there is only one argument — Node: ID
  3. Now we can set selection rules and limit this variant to only Product nodes (Node: ID is bundle "Product")
  4. We set context properly so we can use any node token we like. For more info about available tokens enable Devel and Token modules and go to node/%/devel/token page.
    To use [node:field-term-manufacturer:name] you should input %product_node:field-term-manufacturer:name according to your argument.
    To use [node:field-term-manufacturer:url:path] you should input %product_node:field-term-manufacturer:url:path and so on.
moniuch’s picture

Thanks a lot, your explanation that it works on real URLs rather than aliases cleared a lot.
It'd be useful to place that info on the definition form.

moniuch’s picture

Would you please explain just one more thing.
I found a context labeled String, end the explanation says:
If checked, this string will include all arguments. For example, if the path is "path/%" and the user visits "path/foo/bar", if this is not checked the string will be "foo". If it is checked the string will be "foo/bar".

After what you've explained about the URL aliases, path/foo/bar would never be allowed on the system unless it were an alias. So when would this kind of context be called?

I find myself defining a bunch of simple breadcrumbs which fit a pattern like: site.com/pagetitle (some can be of a certain content type, others are views pages). I was wondering if this sort of breadcrumbs could be addressed by one definition?

kalabro’s picture

After what you've explained about the URL aliases, path/foo/bar would never be allowed on the system unless it were an alias. So when would this kind of context be called?

/**
 * Implements hook_menu().
 */
function MYMODULE_menu() {
  $items['path/foo/bar']  = array(
    // Menu settings
  );
  return $items;
}

Now it is allowed :) The module is really flexible.

moniuch’s picture

Status: Active » Closed (fixed)

Yes, that's true, congratulations!
I understood the path/foo/bar thing right after I made breadcrumbs for a Views page.
Thanks for your patient support, Closing the issue.

kalabro’s picture

Glad to help! You're welcome to prepare most common questions for documentation!

moniuch’s picture

I sent an email to Evgeniy with my observations as a beginner, this might guide you in writing a FAQ section.

moniuch’s picture

Issue summary: View changes

provided node title