/** * Mynodeprevnext * Article on an article next * $nid-Node ID * $type-node type */ function Mynodeprevnext ($nid, $type) { $output = ' <ul> '; $sql _previous = "Select N.nid, N.title, Url.alias" . ' from {node} as n ' . ' Left JOIN {url_alias} as URL ' . "On concat (' node/', N.nid) =url.source" . "WHERE N.nid <: nid and N.type =: type" . "ORDER by N.nid DESC" . "LIMIT 0, 1"; $result _previous = db_query ($sql _previous, Array (': Nid ' => $nid, ': Type ' => $type)); $strings = Array (); foreach ($result _previous as $data) { $data->url = ($data->alias)? $data->alias: '/node/'. $data->nid; $output. = ' <li> previous: ' . ' <a href= '. $data->url. ' "title=". $data->title. ' > ' . $data->title . ' </a> ' . ' </li> '; } $sql _next = "Select N.nid, N.title, Url.alias" . "From {node} as n" . "Left JOIN {url_alias} as URL" . "On concat (' node/', N.nid) =url.source" . "WHERE N.nid >: Nid and N.type =: Type" . "ORDER by N.nid ASC" . "LIMIT 0, 1"; $result _next = db_query ($sql _next, Array (': Nid ' => $nid, ': Type ' => $type)); $strings = Array (); foreach ($result _next as $data) { $data->url = ($data->alias)? $data->alias: '/node/'. $data->nid; $output. = ' <li> Next: ' . ' <a href= '. $data->url. ' "title=". $data->title. ' > ' . $data->title . ' </a> ' . ' </li> '; } $output. = ' </ul> '; return $output; } |