You are here

function rules_action_set_breadcrumb in Rules 6

Action Implementation: Set breadcrumb.

Related topics

File

rules/modules/system.rules.inc, line 84
rules integration for the system module

Code

function rules_action_set_breadcrumb($settings) {
  $titles = explode("\n", $settings['titles']);
  $paths = explode("\n", $settings['paths']);
  $trail = array(
    l(t('Home'), ''),
  );
  for ($i = 0; $i < count($titles); $i++) {

    // Skip empty titles
    if ($title = trim($titles[$i])) {

      // Output plaintext instead of a link if there is a title
      // without a path.
      $path = trim($paths[$i]);
      if (strlen($path) > 0 && $path != '<none>') {
        $trail[] = l($title, trim($paths[$i]));
      }
      else {
        $trail[] = check_plain($title);
      }
    }
  }
  drupal_set_breadcrumb($trail);
}