You are here

private function views_CrumbsMonoPlugin_PageTitle::viewsArgTitle in Crumbs, the Breadcrumbs suite 7.2

Loads the view and determines a breadcrumb item title based on the last argument. This is used for views paths that end with '%'.

Parameters

array $args: Argument values from the url.

Return value

null|string A breadcrumb item title for the last argument, or NULL if none found. This will use the breadcrumb token string configured for the Views arg.

See also

view::_build_arguments()

1 call to views_CrumbsMonoPlugin_PageTitle::viewsArgTitle()
views_CrumbsMonoPlugin_PageTitle::findTitle in plugins/crumbs.views.inc
Find candidates for the parent path.

File

plugins/crumbs.views.inc, line 179

Class

views_CrumbsMonoPlugin_PageTitle
Determines a breadcrumb item title based on the view title of a page view. The same plugin class is used for Views displays with or without arguments.

Code

private function viewsArgTitle(array $args) {

  // Build and initialize the view.
  $view = views_get_view($this->viewName);
  $view
    ->set_display($this->displayId);
  $view
    ->set_arguments($args);

  // Trigger the argument calculation by calling build_title().
  $view
    ->build_title();

  // Check if there are any substitutions to be done.
  // For example the argument is not validated, so no %1 values are desired.
  if (empty($view->build_info['substitutions'])) {
    return NULL;
  }

  // Check the last argument for a breadcrumb item title.
  $last_arg = $this
    ->getRelevantArgument($view->argument);
  if (!isset($last_arg)) {
    return NULL;
  }
  if (!empty($last_arg->options['breadcrumb_enable']) && !empty($last_arg->options['breadcrumb'])) {
    $token_string = $last_arg->options['breadcrumb'];
  }
  elseif (!empty($last_arg->options['title_enable']) && !empty($last_arg->options['title'])) {
    $token_string = $last_arg->options['title'];
  }
  if (!empty($token_string)) {

    // Use decode_entities() to undo duplicate check_plain().
    // See https://drupal.org/comment/7916895#comment-7916895
    return decode_entities(strtr($token_string, $view->build_info['substitutions']));
  }
  return NULL;
}