monoPlugin('blog'); $api->monoPlugin('portfolio'); } /** * Crumbs plugin for blog posts and views. * * This is called "mono", because the findParent() methods return only one * candidate, not an array of them. */ class mycrumbs_CrumbsMonoPlugin_blog implements crumbs_MonoPlugin { function describe($api) { return t('Special crumbs behavior for blogs on blog.hexatrope.com.'); } /** * Paths like taxonomy/term/% */ function findParent__taxonomy_term_x($path, $item) { $term = $item['map'][2]; switch ($term->vocabulary_machine_name) { // TODO: Put your own vocabulary machine name. case 'blog_categories': return 'blog'; } } /** * Paths like node/% * (these are node paths) */ function findParent__node_x($path, $item) { $node = $item['map'][1]; switch ($node->type) { case 'blog_post': $date_string = date('Y/m/d', $node->created); return "blog/$date_string"; } } /** * Paths like blog/% * (that's a view, which can have additional arguments) * * Example: * blog/2012/04/04 does resolve to blog/%, * because blog/%/%/% is not a path in menu_router. * Still, the additional "/04/04" do show up in $path and in * $item['fragments']. * Breadcrumb intended: * blog > blog/2012 > blog/2012/04 > blog/2012/04/04 */ function findParent__blog_x($path, $item) { // Chop off the last fragment of the path. $fragments = $item['fragments']; array_pop($fragments); return implode('/', $fragments); } /** * Override the label for breadcrumb items with path blog/% * (like blog/2012, blog/2012/04, blog/2012/04/04) * * Those breadcrumb pieces should have shortened labels. * Blog > 2012 > 04 > 04. */ function findTitle__blog_x($path, $item) { // The last fragment holds the number we are interested in. $last_fragment = end($item['fragments']); return $last_fragment; } } /** * Crumbs plugin for blog posts and views. * * This is called "mono", because the findParent() methods return only one * candidate, not an array of them. */ class mycrumbs_CrumbsMonoPlugin_portfolio implements crumbs_MonoPlugin { function describe($api) { return t('Special crumbs behavior for portfolio stuff on blog.hexatrope.com.'); } /** * Paths like node/% * (these are node paths) * * This method is not really necessary, the path plugin can do the job just fine. * Either remove, or improve. */ function findParent__node_x($path, $item) { $node = $item['map'][1]; switch ($node->type) { case 'portfolio_item': // TODO: Use the correct field name. if (isset($node->field_portfolio_category)) { // TODO: Determine the category from the term reference field. $category_slug = 'vineyard-missions'; return "portfolio/$category_slug"; } else { return 'portfolio'; } } } /** * Paths like portfolio/category/% */ function findParent__portfolio_category_x($path, $item) { // TODO: What about a new page "portfolio/categories" ? return 'portfolio'; } }