hi

i'm using viewreference to include a view in a node, and i would that the choice list offer name display instead of title display , because the name is the same, but the view plugin not (its to give the choice of gallery display), is it possible ? if yes how ?

thanks

Comments

dawehner’s picture

Project: Views (for Drupal 7) » View reference
Component: block displays » Code

No idea, because this is an issue of the viewrefernce module :)

danielb’s picture

Status: Active » Fixed

In the config check this option:

[ ] Append unique ID in lists.
It is possible for views displays to have the same title, this option will append [view:view_display_n] in lists used by this field to disambiguate the options.

If you're still not happy with that you can override this theme function (if you know how to do that):

<?php
/**
 * Theme the display title for this view display.
 *
 * @param $view
 *  The view object.
 * @param $view_name
 *  The name of the view.
 * @param $display_name
 *  The name of the display to use.
 * @param $append_id
 *  Boolean indicating whether to append a unique id.
 * @return
 *  The display title of this views display.
 */
function theme_viewreference_display_title($view, $view_name, $display_name, $append_id = FALSE) {

  $view->set_display($display_name);
  $display_title = $view->get_title();

  if (!$display_title) {
    // No title, we have to construct a title.
    $display_title = ucfirst($view_name) ." ". strtolower($view->display[$display_name]->display_title);
  }

  if ($append_id) {
    // Append ID for disambiguation in forms (views displays can have the same title).
    $display_title .= " [". $view_name .':'. $display_name ."]";
  }

  return $display_title;
}
?>
aiphes’s picture

thanks for the tips, its better with "Append unique ID in lists"...i go to use it,because i dont know what to do with the theme function.

Status: Fixed » Closed (fixed)

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

donquixote’s picture

Category: Support request » Task
Issue summary: View changes
Status: Closed (fixed) » Active

The correct thing to do here is to show the display title, not the machine name.

  if (isset($view->display[$display_key]->display_title)) {
    $display_title .= ' - ' . $view->display[$display_key]->display_title;
  }

This gets you e.g.

Products - Admin page
Products - Admin: Product names
Orders - Admin page
Orders - Shopping carts
Orders - Data export

Whereas the machine name is usually stuff like block_1, block_2, block_3, not very meaningful.

donquixote’s picture

To clarify the reopen:
This should be implemented in the module itself. People should not have to override the theme hook.

donquixote’s picture

Btw, this module is nice in combination with paragraphs or nestedbox!

donquixote’s picture

Status: Active » Closed (fixed)