Classify content in Views based on distinct values Is there any elegant way to classify content in view, so that content with same value of some field gets the same value from some predefined list? 

For example: I have nodes with entity reference field and would like to get different colors (from pre-defined palette) for different entities referenced through this field.

I know, that this might be solved by using Views PHP field, but this seems to be quite "hacky" to me. Also, classification lists can't be defined in user-friendly way.

Also, it's possible to add another field to referenced entity, which allows us to use this value for classification through views relationship. But this seems to overkill - and even then I would need to use something like Computed field to get randomly generated colors, which are compatible with each other (or use computed field in combination with list field - but that seems to be completely insane).

Do you know about any better solution?
I haven't done this myself, but off the top of my head...

On the node type, I would add a CCK Colour Field to allow the person adding the node to determine a colour for that node. (Then in the content type setting, manage display and hide the colour field).

Then in views, you can add the colour field, and exclude from display.

Then in the same view, add the node reference field you wish to change the colour for (for example node title colour or background colour). (Make sure the colour field is first in the list of view fields)

Then in the view admin, click on advanced, and click "Theme Information". Find the field you wish to override (something like views-view-field--title.tpl.php).

Then copy the field.tpl.php file from the theme folder in the views module folder, and place it in your themes template folder, renaming the file views-view-field--title.tpl.php

You can then place your own php in that template file, around the default $output variable, something like...

$color = $row-&gt;{$field-&gt;color_field};

&lt;div style="color:&lt;?php print $color ?&gt;;"&gt;
&lt;?php print $output ?&gt;
&lt;/div&gt;


I think that's what you mean? Please let me know if I have misread the question.