Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. $query = new EntityFieldQuery();
  2. $query->propertyOrderBy('created', 'DESC');
  3. $query->entityCondition('entity_type', 'node')
  4. ->entityCondition('bundle', 'news')
  5. ->propertyCondition('status', 1)
  6. ->fieldCondition('field_pub_year', 'value', $year, '=');
  7. if(isset($_GET['country_id'])){
  8. $country = $_GET['country_id'];
  9. $query->fieldCondition('field_related_country', 'target_id', $country, '=');
  10. }
  11. if(isset($keywords)){
  12. $query->addTag('search');
  13. }
  14. $result = $query->execute();
  15.  
  16. function hook_query_search_alter(QueryAlterableInterface $query){
  17. $or = db_or()
  18. ->fieldCondition('title', 'value','%'. $keywords .'%', 'LIKE')
  19. ->fieldCondition('body', 'value','%'. $keywords .'%', 'LIKE');
  20. $query->condition($or);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement