I have a view with an entity reference pulling in what I need from a content type. There are, on purpose, titles that are the same.

Is there a way to compare what is output and then only show one of the titles?

I am showing these in a select list.

This is not duplicates, as they are separate entries... so using the Query Settings > Distinct isn't the correct solution in my case.

1 Answer 1


You can use hook_views_pre_render to get at the results array before it is output to the screen.


function my_module_views_pre_render($view) {
  if ($view->name == 'the machine name of the view') {
    foreach ($view->result as $result) {
      // do some kind of comparison and de-duplification

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.