Hi i have one content type with two vocabulary term references one is called category and terms is A,B,C like the 2nd one resources it contains parent with child terms like below hierarchy
Resource 1
Subsection 1
Subsection 2
Subsection 3
Subsection 4
Resource 2
Resource 3
Resource 4
so i want to display articles based on first taxonomy category then 2nd taxonomy resources related items using entity field query below hierarchy
Resource 1
Subsection 1
Article 1
Article 2
Subsection 2
Subsection 3
Subsection 4
Resource 2
Resource 3
Resource 4
below is my code for display only 1st taxonomy based articles fetching but i need to display both cases please help.
<?php
$vocab = taxonomy_vocabulary_machine_name_load('resource_category');
$trees = taxonomy_get_tree($vocab->vid);
$array_tree = array();
$array_tree1 = array();
foreach($trees as $tree)
{
if($tree->depth == 0)
array_push($array_tree,$tree->tid);
}
$i = 0;
foreach($trees as $tree)
{
foreach($tree->parents as $parent)
{
if($parent != 0)
{
$array_tree1[$parent][$i]=$tree->tid;
$i++;
}
//~ if(array_search($tree->tid,$array_tree))
//~ array_push($array_tree1,$tree->tid);
}
}
?>
<ul>
<?php
foreach($trees as $tree)
{
if($tree->depth == 0) {
echo '<li>'.$tree->name;
if(count($array_tree1[$tree->tid]))
echo '<ul>';
foreach($array_tree1[$tree->tid] as $sub)
{
echo '<li>'.$sub.'</li>';
$query_resources = new EntityFieldQuery();
$query_resources->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'resouces')
->propertyCondition('status', NODE_PUBLISHED)
->fieldCondition('field_resource_category', 'tid', '21')
->fieldCondition('field_resources_subcategory');
$result_resources = $query_resources->execute();
if (isset($result_resources['node'])) {
$news_items_resources = array_keys($result_resources['node']);
$news_items_res = entity_load('node', $news_items_resources);
//echo '<pre>';print_r($news_items_res); echo '</pre>';
} else {
echo '<p><strong>No Resources</strong></p>';
}
}
echo '</ul>';
echo '</li>';
}
}
?>