Similar By Term

Another straight forward method for creating a silo structured website in Drupal using any node type is by using the Similar By Term module combined with a custom node template. This will somewhat replicate the Book module's linking structure. It does not contain the hierarchy structure that comes with the Book module. However, it's a quick and dirty method that will get the job done.

Similar By Term

This module will list inside a block the titles of nodes that are all tagged with the same term.

Once you activate the module:

  • go to Administer > Site Building > Blocks.
  • Click on the configure link next to the block titled "Similar entries from ANY vocabulary".
  • Here you can change the default title of the block and specify how many nodes you want to display. By default, it is set to five.
  • Once you save the configuration, activate the block by selecting the block region in the drop down menu. This block will behave similar to the Book Navigation block.

Custom Template

To add the same type of previous/next linking structure that you see at the end of a book page, you will need to create a custom node template. This requires editing the code in your files.

  • First, open the template.php file located in themes/yourtheme.
  • Add the following snippet of code to the end of this file and save.

//next previous links with titles
function next_prev($current_nid, $type, $button_type, $label, $class) {
   $tid = db_result(db_query(db_rewrite_sql("SELECT tid FROM {term_node} WHERE nid = $current_nid;")));
   if (empty($tid)){ //validate that the image 'does' have a tid
    return '';
   }

   switch ($button_type) {
     case 'prev':
       $sort= 'DESC';
       $case = '< ';
       break;
     case 'next':
       $sort = 'ASC';
       $case = '> ';
       break;
     case 'parent':
       $name = db_result(db_query(db_rewrite_sql("SELECT name FROM {term_data} WHERE tid = $tid;")));
       return l($label.$name, "$type/tid/$tid", array('title' => $name, 'class' => $class));
       break;
    
     default:
       return NULL;
       break;
   }
   $sql = "SELECT n.nid, n.title FROM {node} n INNER JOIN {term_node} t ON n.nid = t.nid ";
   $sql .= "INNER JOIN {term_data} r ON t.tid = r.tid WHERE n.type = '". $type ."' AND n.nid ". $case;
   $sql .= $current_nid ." AND r.tid = ". $tid ." AND n.status = 1 ORDER BY nid ". $sort;
   $result = db_fetch_array(db_query(db_rewrite_sql($sql)));
   $newtitle = $result['title'];
   if (!$result) {
     return NULL;
     return l($label.$name, "$type/tid/$tid", array('title' => $name, 'class' => $class));
   } else {
     return l($label.$newtitle, 'node/'. $result['nid'], array('title' => $result['title'], 'class' => $class));
 
   }
}

  • Inside your themes/yourtheme directory, find the file titled 'node.tpl.php'.
  • Copy this file and name it 'node-yournodetype.tpl.php', replacing yournodetype with whatever type you are using. For example, if you want to use the story node type, your file would be node-story.tpl.php.
  • Place the following code snippet where you want the links to appear, usually before the last </div> tags.
  • Replace 'story' with your chosen content type.

<?php
 
if ($terms && arg(0) == 'node' && is_null(arg(2))) {
     
$next = next_prev($node->nid, 'story', 'next', '', 'link');
     
$previous = next_prev($node->nid, 'story', 'prev', '', 'link');
      print
'<p><center>';
      if (
$previous){ print '<&nbsp;' . $previous;}
      print
'&nbsp;&nbsp;|&nbsp;&nbsp;';
      if (
$next){ print $next . '&nbsp;>';}
      print
'</center></p>';
    }
?>

This will display the linked titles of both the previous and next nodes that are tagged with the same taxonomy term. They are sorted by node id rather than weight.

Posted In

This is something not very

This is something not very good, I really never thought something like that in my weird dreams even! vinilos

haiko7 | Sat, 02/06/2010 - 04:40

we offers free 000-081 exam

we offers free 000-081 exam dumps and 000-081 Practice exam,000-081 exam questions for IBM certifications III certification(IBM Certified Network Associate). You can check out the question quality and usability of our 000-081 practice exam before you decide to buy it.Before you purchase our 000-081 Q&A,you can click the link below to download the latest 000-081 pdf dumps.

Acquiring IBM IBM certifications III certifications are becoming a huge task in the field of I.T. More over these exams like 000-081 exam are now continuously updating and accepting this challenge is itself a task. This 000-081 practice test is an important part of IBM certifications and at IBM certifications III braindumps we have the resources to prepare you for this. The 000-081 exam is essential and core part of IBM certifications and once you clear the exam you will be able to solve the real time problems yourself.Wamt to take advantage of the Real 000-081 Value Pack and save time and money while developing your skills to pass your ‘IBM Certified Network Associate (IBM certifications III) Exam’? Let itcerthome help you climb that ladder of success and pass your 000-081 now!

annared | Tue, 02/02/2010 - 10:12

We are offering a

We are offering a comprehensive 1Y0-A05 set of learning materials will be supplied to support the course, which are also designed to act as a valuable data resource going forward. A certificate of ccnp certification will be supplied to all successful candidates. VCA is more than happy to talk to you about VCP-410 or internal training, but this can be dependant upon your certification status. For further information, or to book this course, please contact us.

bysshe | Wed, 11/11/2009 - 07:33

I have built a website for

I have built a website for ged practice test through Similar By Term module and its really wonderful...

brigham | Sat, 08/29/2009 - 05:01