现在我想获取节点标题列表,并在术语页面上显示它。如果我知道id这个词。我如何在这个术语id下获得节点标题?谢谢。例如:术语id为2. drupal版本为6 这是查询,
$query = "SELECT n.nid, n.title FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid = arg(2)";
但我不知道如何分页并将其输出到列表中?
答案 0 :(得分:1)
一种更简单的方式是视图,可以是块或页面(可以替换分类术语页面)。如果你想要代码,这样的东西应该有效:
<?php
$items = array();
$result = pager_query("SELECT n.nid, n.title FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid = %d", arg(2), 0, 10);
while ($row = db_fetch_object($result)) {
$items[] = l($row->title, 'node/' . $row->nid);
}
print theme('item_list', $items, t('Nodes in this category'));
print theme('pager');
答案 1 :(得分:0)
$query = "SELECT n.nid, n.title FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid = %d";
$results = db_query($query,arg(2));
// define table headers(th)
$header = array(
array('data' => t('Node NID')),
array('data' => t('Node Title')),
);
//define rows in table
while($row = db_fetch_array($res)){
$rows[] = array ($row[nid],$row[title]);
}
//leave the theming to hands of Drupal
echo theme('table',$header,$rows);