5

I've created an entity query to get an array of nodes based on a specific content type,see below:

$query = new EntityFieldQuery();        
$query->entityCondition('entity_type', 'node');
$query->entityCondition('bundle', 'article');
$query->propertyCondition('status', 1, '=');
$result = $query->execute();    
$nodes = node_load_multiple(array_keys($result['node']));

The node content type article being queried has a Term Reference field (list of tags). Each taxonomy term is sorted via the admin/structure/taxonomy/tags administration screen.

I have the requirement to have the nodes sorted by term weight. For example the nodes that reference the highest weighted taxonomy term will be at the top.

Is there a way to add a relationship to the taxonomy table using EntityQuery, or is there another way to do this?

1 Answer 1

2

Since the weight is kept in a different table than the one that stores the data related to your node, I'm afraid this is impossible using EntityFieldQuery. You'll have to do some custom coding after the query.

By the way, to use data from the reference field (field_data_your_reference) you could use a fieldCondition or fieldOrderBy.

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.