Since I couldn't find anything with regards to a related content module I decided to modify the anynews module to serve my needs.
Its very basic for now and is called with relevant_content(); in a code section or inside the template with the full PHP tags.
The code looks at the page_title and page_keywords to create the results so even if you dont have keywords on the page it will still return some results.
I added the code into the anynews module. I recommend adding the following code to your include file instead of using my anynews module. It has been hacked to suit my needs.
if (!function_exists('relevant_content')) {
function relevant_content($group_id=0, $max_news_items=10, $max_news_length=6, $display_mode=2, $header_text="",
$readmore_text="read more", $no_news_text="No related content...", $strip_tags=true) {
// group_id... group from which you want to read news from (default:= 0 for all groups)
// max_news_items... maximal number of news shown (default:= 10, no value >10 accepted)
// max_news_length... maximal length of the short news text shown (default:=-1 for full news length)
// display_mode... 1:=details (default); 2:=unsorted list
// header_text... heading text shown (default:="Latest news")
// readmore_text... text displayed for readmore link (default:=read more)
// no_news_text... text shown if no news available (default:="no news avaialbe yet...")
// strip_tags... true:=remove all PHP/HTML/JS tags from string inputs (default); false:=don´t strip tags
// register outside object
global $database;
// convert all numeric inputs to integer variables
$group_id = (int) $group_id;
$max_news_items = (int) $max_news_items;
$max_news_length = (int) $max_news_length;
$display_mode = (int) $display_mode;
$strip_tags = (bool) $strip_tags;
// do some sanity checks of arguments passed by the user
if($max_news_items > 9 || $max_news_items < 1) {
$max_news_items = 10;
}
if($max_news_length < -1) {
$max_news_length = -1;
}
if($display_mode < 0 || $display_mode > 2) {
$display_mode = 1;
}
// strip tags if specified
if($strip_tags) {
$header_text = strip_tags($header_text);
$readmore_text = strip_tags($readmore_text);
$no_news_text = strip_tags($no_news_text);
}
// query to obtain news items for the selected group
//get Current Page Keywords for related content.
if ($group_id < 1) {
$sql = 'page_title="impossiblenametoguess"';
$keywords = explode(" ",PAGE_TITLE);
foreach ($keywords AS $k=>$v) {
$v = eregi_replace("&", "", $v);
if($v!=''){//echo " OR keywords LIKE '%$v%";
$sql.= " OR page_title LIKE '%$v%'"; }
}
foreach ($keywords AS $k=>$v) {
$v = eregi_replace("&", "", $v);/*
$v = eregi_replace("or;", "", $v);
$v = eregi_replace("the;", "", $v);
$v = eregi_replace("a;", "", $v);
$v = eregi_replace("to;", "", $v);
$v = eregi_replace("in", "", $v);
$v = eregi_replace("are", "", $v);
$v = eregi_replace("on", "", $v);
$v = eregi_replace("at", "", $v);
$v = eregi_replace("an", "", $v);*/
if($v!=''){//echo " OR keywords LIKE '%$v%";
$sql.= " OR keywords LIKE '%$v%'"; }
}
//echo $sql;
$query = "SELECT * FROM " .TABLE_PREFIX ."pages WHERE pages.visibility='public' AND ( ".$sql.") ORDER BY page_title DESC LIMIT 0, $max_news_items;";
} else {
$query = "SELECT * FROM " .TABLE_PREFIX ."pages WHERE visibility='public' ORDER BY modified_when DESC LIMIT 0, $max_news_items;";
}
// make database query and obtain number of news items found
$result = $database->query($query);
$number_news = $result->numRows();
// write out news header
echo "\n<!-- Display news items anywhere -->\n";
//if ($header_text != "") {
echo "<h3>Related Content</h3>\n";
// }
// output all new itmes found
$output = "";
if($number_news) {
while($data = $result->fetchRow()) {
// strip tags if specified
if($strip_tags) {
$data['page_title'] = strip_tags($data['page_title']);
$data['content_short'] = strip_tags($data['content_short']);
}
// shorten news text to defined news length (-1 for full text length)
if($max_news_length != -1 && strlen($data['content_short']) > $max_news_length) {
$data['content_short'] = substr($data['content_short'], 0, $max_news_length) ."...";
}
// output news items depending on choosen display mode
if($display_mode == 2) {
// OUTPUT NEWS ITEMS AS UNSORTED LIST
if ($data['page_title'] != "") {
$output .= "<li><a href=\"" .WB_URL.PAGES_DIRECTORY .$data['link'] .PAGE_EXTENSION." \">" .$data['page_title'] ."</a></li>\n";
}
} else {
// OUTPUT NEWS ITEMS WITH NEWS TITLE, SHORT NEWS TEXT AND READ MORE LINK
if ($data['title'] != "") {
$output .= "<p><strong>" .$data['title'] ."</strong></p>\n";
}
if($max_news_length !== 0 ) {
$output .= "<p>" .$data['content_short'] ."</p>\n";
}
$output .= "<p><a href=\"" .WB_URL.PAGES_DIRECTORY .$data['link'] .PAGE_EXTENSION ."\">" .$readmore_text ."</a></p>\n";
$output .= "<hr />\n";
}
}
// add unsorted list tags if display option is set
if($display_mode == 2) {
$output = "<ul>\n" .$output ."</ul>\n";
}
// write out full news items string
echo $output;
} else {
echo "<p><strong>" .$no_news_text ."</strong></p>\n";
}
}
}
I take no responsibility for this code and I recommend you make a backup of all the files you plan to modify. Use at own risk.