I have the views listing page.it has nodes of same taxonomy term - whats new.Now when I click on the nodes of the view, it should show me the next and previous link of the views.Can any one help me in the issue.

Comments

swetaranjan7@yahoo.in’s picture

<?php
<?php
<?php

?>
?>
?>[SOLVED]

I added below code in template.php

function node_sibling($dir = 'next', $node, $next_node_text=NULL, $prepend_text=NULL, $append_text=NULL, $tid = FALSE){
if($tid){

$query = 'SELECT n.nid, n.title FROM {node} n INNER JOIN {taxonomy_index} tn ON n.nid=tn.nid WHERE '
. 'n.nid ' . ($dir == 'previous' ? '<' : '>') . ' :nid AND n.status=1 '
. 'AND tn.tid = :tid ORDER BY n.created ' . ($dir == 'previous' ? 'DESC' : 'ASC');
//use fetchObject to fetch a single row
$row = db_query($query, array(':nid' => $node->nid, ':tid' => $tid))->fetchObject();
}else{
$query = 'SELECT n.nid, n.title FROM {node} n WHERE '
. 'n.nid ' . ($dir == 'previous' ? '<' : '>') . ' :nid AND n.type = :type AND n.status=1 '
. 'ORDER BY n.nid ' . ($dir == 'previous' ? 'DESC' : 'ASC');
//use fetchObject to fetch a single row
$row = db_query($query, array(':nid' => $node->nid, ':type' => $node->type))->fetchObject();
}
if($row) {
$text = $next_node_text ? $next_node_text : $row->title;
return drupal_get_path_alias('node/'.$row->nid) ;
} else {
return FALSE;
}
}

It helped me in making next and previous node in content pages of nodes.

Then I called the function in my node.tpl.php

$Next = node_sibling('next',$node,NULL,NULL,NULL,FALSE);
$Previous = node_sibling('previous',$node,NULL,NULL,NULL,FALSE);

mustanggb’s picture

Priority: Critical » Normal
renatog’s picture

renatog’s picture

Status: Active » Fixed
Issue tags: +ciandt-contrib

Hi @swetaranjan7, how are you?

How nice that it worked.

Thank you very much for share your solution for this question.

Good Work.

Regards.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.