I have a content type "Person" which has a field called "state". On the node page of any "person", I want to display other nodes of "Person" which has the same value for the "state" field.
For e.g. If a we are on a person node who is from New York, the view block placed on this node should display other persons from New York.

I know how this could be done if it were node id, or term id : using contextual filters and getting content id from URL, etc. However, I'm not sure how do I get this from other text field like "state".

Any pointers would be appreciated.

2 Answers 2


I think you need use the field type "list" or the field type "Taxonomy term".

  • 1
    Thanks for your reply, in our project we have to taken field type "text". so can you pls suggest any option using field type "text". Commented Sep 16, 2014 at 8:35

I don't know if it is possible with Views UI. But you could always recover your "field_state" value manually by getting the current node (assuming you're running the code in a node page):

$node = menu_get_object();
$state = $node->field_state[LANGUAGE_NONE][0]['value'];

And then use that value to look for other similar nodes, for example with EntityFieldQuery:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'person')
  ->fieldCondition('field_state', 'value', $state, '=');
$results = $query->execute();

And display the results with theme_table maybe.

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.