i have a news aggregator project. in this project i have categories like this.
- sport
- sport:football (tick)
- sport:basketball(tick)
- sport:volleyball
- sport:Tennis
- politic
- politic:your country (tick)
- politic:others
above tree shows how users want news to be aggregated.
i save all selected and not selected taxonomies in two different variable for each user in database as an array width function variable_set
now i want in sport taxonomy page, default drupal page, only shows nodes that football and basketball is their category, and nodes from tennis and volleyball will not be shown.
i mean overriding behaviour of default taxonomy pages. i know this can happen with views module buttttt number of taxonomies is not fixed. it will be more and more during the life of the news aggregator website. now the number of them now is more than 340 taxonomies.
now i have written this code. this code. this codes works well but i want in parent taxonomy page, nodes shows that user collected their subchildren taxonomy.
function caspian_bartik_menu_alter(&$menu) {
$menu['taxonomy/term/%taxonomy_term']['page callback'] = 'caspian_bartik_term_page';
$menu['taxonomy/term/%taxonomy_term']['access arguments'] = array('access content');
$menu['taxonomy/term/%taxonomy_term']['page arguments'] = array(2);
}
function caspian_bartik_term_page($term){
$voc = taxonomy_vocabulary_load($term->vid);
// here you generate the actual content of the page
// could be done e.g. with an entityfieldquery as follows
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->fieldCondition('field_category', 'tid', $term->tid , '=')
->fieldCondition('field_category', 'tid', array(135) , 'NOT IN')
->propertyOrderBy('created', 'DESC');
$result = $query->execute();
if (!empty($result['node'])) {
$build['content']['nodes'] = node_view_multiple(node_load_multiple(array_keys($result['node'])), 'teaser');
} else {
$build['content']['status']['#markup'] = t('No results found for term ID !tid.', array('!tid' => $term->tid));
}
return $build;
}
this line does not work
->fieldCondition('field_category', 'tid', array(135) , 'NOT IN')
thanks for your help.