Hello, comrades.
I want to output news titles on the page (without teasers and other stuff). Picture demonstrate this:
http://www.comics.com.ua/images/news.gif
I wrote such code:
<?php
function title_list($result, $title = NULL) {
$dt = "";
$cond = 0;
$out = "";
while ($node = db_fetch_object($result)) {
$a = getdate($node->created);
if ($cond == 0)
{
$y = $a['year'];
$m = $a['mon'];
$d = $a['mday'];
$dt = "<p><b>".$d.".".$m.".".$y."</b></p>";
$out = $out.$dt;
$cond = 1;
}
else
if (($y != $a['year']) || ($m != $a['mon']) || ($d != $a['mday']))
{
$out = $out.theme('node_list', $items, $title);
UnSet($items);
$a = getdate($node->created);
$y = $a['year'];
$m = $a['mon'];
$d = $a['mday'];
$dt = "<p><b>".$d.".".$m.".".$y."</b></p>";
$out = $out.$dt;
}
else
$dt = "";
$number = module_invoke('comment', 'num_all', $node->nid);
$items[] = l($node->title, 'node/'. $node->nid, $number ? array('title' => format_plural($number, '1 comment', '%count comments')) : '');
}
return $out.theme('node_list', $items, $title);
}
global $user;
if (user_access("access content"))
{
$stories = "";
$queryResult = db_query_range("SELECT n.uid, u.name, max(n.nid) FROM {node} n INNER JOIN {users} u ON u.uid = n.uid WHERE n.type = 'story' AND n.status = 1 GROUP BY n.uid, u.name ORDER BY 3 DESC", 0, 10);
while ($node = db_fetch_object($queryResult))
{
$stories .= title_list(db_query_range("SELECT n.title, n.nid, n.created FROM {node} n WHERE n.type = 'story' AND n.status = 1 AND n.uid = " . $node->uid . " ORDER BY n.nid DESC", 0, 10));
}
print $stories
. "
". l(t("more"), "story", array("title" => t("Просмотреть остальные новости."))) ."
";
}
?>
It works fine, but it output titles of ALL materials from ALL vocabularies. How to modify SQL-query for outputting titles of only ONE vocabulary (f.e. "News")?