¿Cómo aplicar una condición de taxonomía usando EntityFieldQuery?
Frecuentes
Visto 896 veces
0
I have a content type where there is a tag field that is a taxonomy term.I would like to make a query to get all the nodes that contain the $tag
variable inserted by the user. I know how to do it using db_query
pero si uso EntityFieldQuery
seems that I cannot apply a join.
How can I do it? Do I have to use db_query
?
1 Respuestas
1
An EntityFieldQuery
doesn't allow for IS NOT NULL
or similar conditions, so there's no way to query for all nodes that contain a value for a particular field. You can only query nodes that have a soluciones value for a particular field.
They're also self-contained, so there's no way to add an extra join unless you implement hook_query_alter()
and physically add the join once the query has been converted from an EntityFieldQuery
a un estándar SelectQuery
. That, or sub-class EntityFieldQuery
and add the new logic yourself.
That said you'll need to form the query yourself. If you're just querying for nodes though, I'd advise using the taxonomy_index
table rather than the field tables, as that will produce cleaner queries and make life easier further down the line.
Respondido 28 ago 12, 14:08
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas drupal-7 drupal-taxonomy or haz tu propia pregunta.