Posted by runeveryday on December 7, 2012 at 8:24am
on the parent term page, i want to get all the node belong to it( should output node title, a field i created to the content type. node summary). which tables should i query? thank you.
on the parent term page, i want to get all the node belong to it( should output node title, a field i created to the content type. node summary). which tables should i query? thank you.
Comments
Hi You want to fetch the
Hi
You want to fetch the result from table using db_query, But in drupal way you can create a view,use tid as argument and choose field which you want.
I think it's helpful for you.
but if i don't want to use
but if i don't want to use views.how do i do?
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'product')
->propertyCondition('status', 1)
->fieldCondition('field_fenlei', 'tid', arg(2))
->range(0, 10);
$result = $query->execute();
if (isset($result['node'])) {
$nids = array_keys($result['node']);
$nodes = entity_load('node', $nids);
echo $nodes->title;
}
why the above code doesn't work
Try this. I think its working
Try this. I think its working for you.
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'product')
->propertyCondition('status', 1)
->fieldCondition('field_fenlei', 'tid', arg(2))
->range(0, 10);
$result = $query->execute();
if (isset($result['node'])) {
$nids = array_keys($result['node']);
$nodes = entity_load('node', $nids);
foreach($nodes as $nod)
echo $nod->title;
}