I have a View called clients_associations. In this View I have added a page called Non-Profit Organizations. This is the "Name" of that specific page view within the overall clients_associations View.

When I output my View Reference field on my node as a Title (Link) I get both the output of the View name and the page View name. How can I only output the Page View name. I don't want both.
So this is what I'm getting on the View Ref output (Type here is the label):

Type: Clients_associations Non-Profit Organizations

I just want it to say:

Type: Non-Profit Organizations

Suggestions?

-backdrifting

Comments

danielb’s picture

It would have something to do with this theme function

<?php

/**
 * Theme function for 'link' nodereference field formatter.
 */
function theme_viewreference_formatter_link($element) {
  $output = '';
  if (!empty($element['#item']['view_id']) && is_numeric($element['#item']['view_id'])) {
    $view = db_fetch_object(db_query("SELECT name, position, title FROM {viewreference} WHERE view_id = '%d'", $element['#item']['view_id']));
    if ($view) {
      $view_object = views_get_view($view->name);
      if ($view_object && $view_object->access($view->position)) {
        $title = $view_object->get_title() ? $view_object->get_title() : $view->title;
        if (isset($view_object->display[$view->position]->display_options['path']) && !$view_object->disabled) {
          $args = viewreference_get_element_args($element);
          $url_args = implode("/", $args);
          $path = $view_object->display[$view->position]->display_options['path'];
          if ($url_args) {
            $path .= "/". $url_args;
          }
          $output .= l($title, $view_object->get_url($args, $path));
        }
        else {
          $output .= check_plain($title);
        }
      }
    }
  }
  return $output;
}

?>

You can override theme functions, as you might know to suit yourself. Perhaps you could investigate the code here to figure out what's going on.

$view - The data View Reference has about the chosen view
$view_object - The data returned from the views module based on the data from $view

$view_object->get_title() - This should be the correct title on the view?
$view->title - This would be the undesired long title used in the selection forms, it is used on the node view as a fallback when $view_object->get_title() is null/false/empty/0

$title = $view_object->get_title() ? $view_object->get_title() : $view->title;

That line in particular, perhaps just before it, debug what $view_object->get_title() is returning.

lol the comment says nodereference, woops

danielb’s picture

It's possible the more correct title you're after is actually in $view_object->display[$view->position]

danielb’s picture

Hmm it seems there a few problems relating to this. Even with the listings. The title of the display is in $view->display->(display position)->display_options['title'], but if it's not there then look for the same where the display position is 'default'. Bit confusing.

So I might have to remember "view-name display-key", the display title, as well as the display options title.

danielb’s picture

I've made this change for the node config stuff in my development copy, but I still need to make it work on the node edit page, and for the output theme functions before I commit.

danielb’s picture

oh man i got drunk and rewrote teh whole module, except for the actual issue I was meant to fix

danielb’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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