Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $query = new EntityFieldQuery();
- $query->propertyOrderBy('created', 'DESC');
- $query->entityCondition('entity_type', 'node')
- ->entityCondition('bundle', 'news')
- ->propertyCondition('status', 1)
- ->fieldCondition('field_pub_year', 'value', $year, '=');
- if(isset($_GET['country_id'])){
- $country = $_GET['country_id'];
- $query->fieldCondition('field_related_country', 'target_id', $country, '=');
- }
- if(isset($keywords)){
- $query->addTag('search');
- }
- $result = $query->execute();
- function hook_query_search_alter(QueryAlterableInterface $query){
- $or = db_or()
- ->fieldCondition('title', 'value','%'. $keywords .'%', 'LIKE')
- ->fieldCondition('body', 'value','%'. $keywords .'%', 'LIKE');
- $query->condition($or);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement