Posted by Spider84 on January 22, 2013 at 1:08pm
I know how to create, load and save node programmatically.
But I want to find the node(or nodes) by some field value prorgrammatically. Is it possible?
Thanks.
I know how to create, load and save node programmatically.
But I want to find the node(or nodes) by some field value prorgrammatically. Is it possible?
Thanks.
Comments
yes it is
you can find nodes with SQL Query.
See this http://drupal.org/node/1889184 for clue
entity query + Drupal 7
Hi
I think you can find any node with on its node base by using entity query .
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'article')
->propertyCondition('status', 1)
->fieldCondition('field_news_types', 'value', 'spotlight', '=')
->fieldCondition('field_photo', 'fid', 'NULL', '!=')
->fieldCondition('field_faculty_tag', 'tid', $value)
->fieldCondition('field_news_publishdate', 'value', $year. '%', 'like')
->range(0, 10)
->addMetaData('account', user_load(1)); // Run the query as user 1.
$result = $query->execute();
skype #id :
asghar.khan5
contact# +923326684082
Can I use this for node
Can I use this for node refernce type fields?
See
See EntityFieldQuery::addFieldCondition.
This sets up a database query, so you have to search on a schema column for the field. I don't know how node reference fields work, so you'll have to answer that yourself.
If you just want to follow a reference field, well, there must be some way to extract it, right? So,
$nid = (however you extract that from the reference field).
...
->propertyCondition('nid', $nid)
--
www.ztwistbooks.com. Math books that are actually fun.