Есть хук:
<?phpfunction Natali_prevnext($nid,$ntype) {
//This selects the previous record and builds it into an HTML string using the Drupal "l" function to build the link
$result = db_query("SELECT nid, title FROM {node} WHERE nid < %d AND type = '%s' AND status = 1 ORDER BY nid DESC LIMIT 1",$nid,$ntype);
while ($row = db_fetch_array($result)) {
$outputstring .= "<div class='prevpost'>« " . l(t($row[title]),"node/".$row[nid], array(attributes => array('title'=> t($row[title])))) . "</div>" . $row[filepath];
}
//This selects the next record and builds it into an HTML string as in the previous example
$result = db_query("SELECT nid, title FROM {node} WHERE nid > %d AND type = '%s' AND status = 1 ORDER BY nid ASC LIMIT 1",$nid,$ntype);
while ($row = db_fetch_array($result)) {
//Finally, we wrap the output in a containing DIV element for themeing purposes
$outputstring .= "<div class='nextpost'>" . l(t($row[title]),"node/".$row[nid], array(attributes => array('title'=> t($row[title])))) . " »</div>";
}
$outputstring = "<div class='post-navigation clearfix'>" . $outputstring . "</div>";
print $outputstring;
}?>
Он прекрасно работает, но если поменять запрос на вот такой:
<?php $result = db_query("SELECT shop_node.nid
, shop_node.title
, shop_files.filepath
FROM
shop_node
INNER JOIN shop_content_field_image_cache
ON shop_node.nid = shop_content_field_image_cache.nid
INNER JOIN shop_files
ON shop_content_field_image_cache.field_image_cache_fid = shop_files.fid
WHERE
shop_node.nid < %d
AND shop_node.type = '%s'
AND shop_node.status = 1
ORDER BY
shop_node.nid DESC
LIMIT
1",$nid,$ntype);
?>
Ни чего не выводится, хотя если руками подставить nid и выполнить запрос, то картинку получаем.
В чём может быть проблема. Может как-то по другому сделать запрос?
Комментарии
Подписываюсь