How to make this code work on 5.7 ?

poseidon123 - December 26, 2008 - 12:27

well http://www.gerd-riesselmann.net/archives/2005/11/display-related-nodes-i... has a great hack which I had used on 4.7 some years back but now I am trying to use it and its not working. Here is the code -

<?php if ($page != 0)
{  
$words = search_index_split($node->title);  
    
$searchArgs = "";  
     foreach(
$words as $word)
     {    
           if (
strlen($word) > variable_get('remove_short', 3))
           {      
                     if (!empty(
$searchArgs))
                     {        
$searchArgs .= " OR ";       }      
                    
$searchArgs .= $word . " ";    
           }  
     }  
    if (
strlen($searchArgs) > 0)
    {    
          
$results = node_search('search', $searchArgs);    
           if (
is_array($results) && count($results) > 0)
           {       print
'<hr />';      
                   print
'<div id="related_nodes">';      
                   print
'<h2>The following articles may be of interest to you, too:</h2>';      
                  
$list = array();      
                  
$count = 0;             
                   foreach(
$results as $item)
                   {       
                            if (
$item['title'] == $node->title)
                            {           continue;         }        
                  
$list[] = l($item['title'], ltrim($item['link'], '/')) .": " .strip_tags($item["snippet"]);
                   if (++
$count > 4) {           break;         }      
            }       print
theme("item_list", $list);      
            print
"</div>";    
     }  
}
}
?>

i am trying to use it for a content type how2 by putting it in node-how2.tpl.php file but its not working. so I put it in node.tpl.php and still the code is not working, for any content type. Any idea what is going wrong here ?

anyone ?

poseidon123 - January 2, 2009 - 11:19

Nevermind, I got it working. The code is fine :)

 
 

Drupal is a registered trademark of Dries Buytaert.