Posted by prasadrao on November 7, 2012 at 6:02am
Hello,
I want to display title of posts(node title) in Web site URL /citylisting/taxonomy/term/22 in the block. This means this URL has some posts. I want to display all the posts titles in a Block. I tried to write many SQL queries in Drupal 7 Block . But nothing is working.
Prasad
Comments
Use ViewsBlock
Hi
You can create a Views Block for particular tid or as per your required condition. Show only node title in display field section.
Your block will be created which contain all node titles of current tid.
You can also apply many more condition.
It may helpful for you.
Abhishek
Cannot use views
Thank you. I dont want to use views as there are many URL's and I am displaying these based on some condtion(session). How can I fetch the posts (titles) related to a term id and display them in a block?
Using custom code
Another way to doing this, use custom code to get node title of particular tid:
Like:
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'YOUR_CONTENT_TYPE_HERE')
->fieldCondition('field_name', 'tid', 5);
$result = $query->execute();
$nids = array_keys($result['node']);
$nodes = entity_load('node', $nids);
and use the result to custom block etc.