Vielleicht kennen einige von euch das Modul Mozak-News. News-Überschriften können sortiert nach Themen auf der Hauptseite oder als Modul in 2 Balken aufgelistet werden. Das Modul listet alle Überschriften auf aber sid der Nachricht wird irgendwie nicht übernommen und man bekommt als link sowas
http://www.blabla.com/modules.php?name=News&file=article&sid=
Könnte vielleicht jemand mir helfen, wie ich dieses Problem lösen kann!
Das Modul kann man sich hier runterladen
http://www.nukeresources.com/downloadview-details-779-Mozaks_News_for_Nuke_6.5_&_up.html
Und hier ist der Code, für die Leute die sich das Modul nicht runterladen möchten!
<?php
if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
die ("You can't access this file directly...");
}
/* Stories setting */
$limit = 5; // display how many articles per topic
$index = 1;
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
// Function to cut long text
function cut($str,$max){
$count = strlen($str);
if($count >= $max) {
for ($pos=$max;$pos>0 && ord($str[$pos-1])>=127;$pos--);
if (($max-$pos)%2 == 0)
$str = substr($str, 0, $max) . "...";
else
$str = substr($str, 0, $max+1) . "...";
return $str;
}
else {
$str = "$str";
return $str;
}
}
function index(){
global $limit, $prefix, $db, $module_name;
include("header.php");
$copy = "<p align=right><A HREF=\"http://www.mozaks.com\" target=\"_blank\">Powered by Mozaks News 0.2</A></p>";
$sql = "SELECT topicid,topicname,topictext FROM ".$prefix."_topics where displayhome='1' ORDER BY displayorder";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$topicid = $row[topicid];
$topicname = $row[topicname];
$topictext = $row[topictext];
$cnt = $db->sql_numrows($db->sql_query("SELECT sid FROM ".$prefix."_stories where topic=$topicid"));
if ($cnt > 0){
OpenTable();
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\" width=\"100%\" align=\"center\">\n"
."<tr>\n"
// Topics
."<td><B>:: $topictext</B></td>\n"
// Link to topic
."<td align=right> <a href=\"modules.php?name=News&new_topic=".$topicid."\">more..</a> </td>\n"
."</tr>\n"
."</table>\n";
// Bold line below topic title
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"100%\">\n"
."<tr>\n"
// Topic line's color. You could change the color code to suit your theme
."<td height=0 bgcolor=\"#cccccc\"><img src=modules/Mozaks_News/img/pixel.gif width=1 height=1></td>\n"
."</tr>\n"
."</table>\n";
// Here you could limit the news shown in a topic by changing the
// value 'limit 5' to 'limit 10' or whatever you want. Default is 5.
$sql2 = "SELECT sid, catid, aid, title, time, comments, counter, topic, informant, score, ratings FROM ".$prefix."_stories where topic=$topicid ORDER BY sid DESC limit 0,$limit";
$result2 = $db->sql_query($sql2);
while ($row2 = $db->sql_fetchrow($result2)) {
$s_sid = $row2[sid];
$catid = $row2[catid];
$aid = $row2[aid];
$title = $row2[title];
$time = $row2[time];
$comments = $row2[comments];
$counter = $row2[counter];
$topic = $row2[topic];
$informant = $row2[informant];
$score = $row2[score];
$ratings = $row2[ratings];
$r_options = "";
if (isset($cookie[4])) { $r_options .= "&mode=$cookie[4]"; }
if (isset($cookie[5])) { $r_options .= "&order=$cookie[5]"; }
if (isset($cookie[6])) { $r_options .= "&thold=$cookie[6]"; }
$Y = substr($time, 0, 4);
$M = substr($time, 5, 2);
$D = substr($time, 8, 2);
// Date (D=day, M=month, Y=year) - can be changed to other format such as $M.".".$D.",".$Y;
$time = $Y.".".$M.".".$D;
// Cut the long title to avoid stretch on the table.
// The value '35' is the lenght of the text.
// You may change it to suit your theme. Default is 35.
$title = cut($title,35);
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n"
."<tr><td>\n"
."<table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"100%\">\n"
."<tr height=20 onmouseover=\"this.style.backgroundColor='#eeeeee'\" onmouseout=\"this.style.backgroundColor=''\">\n"
// News titles begin from here
."<td align=\"left\"> <strong><big>·</big></strong>"
." <a href=\"modules.php?name=News&file=article&sid=$s_sid$r_options\">$title</a></td>\n"
// Here you can add more info of the news at the ($comments comments)
// such as ($counter reads) or (Informant: $informant) or (Score: $score).
."<td align=\"right\">($comments comments) $time </td>\n"
."</tr></table></td></tr></table>\n"
."<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" align=\"center\">\n"
."<tr>\n"
."<td height=1 background=\"modules/Mozaks_News/img/dot.gif\"></td>\n"
."</tr>\n"
."</table>\n";
}
CloseTable();
}
echo "<BR>";
}
echo $copy;
include("footer.php");
}
switch ($op) {
default:
index();
break;
}
?>
Hallo
Dieser überarbeitete Code hat bei mir funktioniert.
Habe allerdings das Modul NICHT installiert und meine Topics-Tabelle verändert. Habe mit geänderter erster Querie gearbeitet und das ging.
<?php
if (!defined("mxMainFileLoaded")) die ("You can't access this file directly...");
/* Stories setting */
$limit = 5; // display how many articles per topic
$index = 1;
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
// Function to cut long text
function cut($str,$max){
$count = strlen($str);
if($count >= $max) {
for ($pos=$max;$pos>0 && ord($str[$pos-1])>=127;$pos--);
if (($max-$pos)%2 == 0)
$str = substr($str, 0, $max) . "...";
else
$str = substr($str, 0, $max+1) . "...";
return $str;
}
else {
$str = "$str";
return $str;
}
}
function index(){
global $limit, $prefix, $db, $module_name;
include("header.php");
$copy = "<p align=right><A HREF=\"http://www.mozaks.com\" target=\"_blank\">Powered by Mozaks News 0.2</A></p>";
$sql = "SELECT topicid,topicname,topictext FROM ".$prefix."_topics where displayhome='1' ORDER BY displayorder";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$topicid = $row['topicid'];
$topicname = $row['topicname'];
$topictext = $row['topictext'];
$cnt = $db->sql_numrows($db->sql_query("SELECT sid FROM ".$prefix."_stories where topic=$topicid"));
if ($cnt > 0){
OpenTable();
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\" width=\"100%\" align=\"center\">\n"
."<tr>\n"
// Topics
."<td><B>:: ".$topictext."</B></td>\n"
// Link to topic
."<td align=right> <a href=\"modules.php?name=News&new_topic=".$topicid."\">more..</a> </td>\n"
."</tr>\n"
."</table>\n";
// Bold line below topic title
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"100%\">\n"
."<tr>\n"
// Topic line's color. You could change the color code to suit your theme
."<td height=0 bgcolor=\"#cccccc\"><img src=modules/Mozaks_News/img/pixel.gif width=1 height=1></td>\n"
."</tr>\n"
."</table>\n";
// Here you could limit the news shown in a topic by changing the
// value 'limit 5' to 'limit 10' or whatever you want. Default is 5.
$sql2 = "SELECT sid, catid, aid, title, time, comments, counter, topic, informant, score, ratings FROM ".$prefix."_stories where topic=$topicid ORDER BY sid DESC limit 0,$limit";
$result2 = $db->sql_query($sql2);
while ($row2 = $db->sql_fetchrow($result2)) {
$s_sid = $row2['sid'];
$catid = $row2['catid'];
$aid = $row2['aid'];
$title = $row2['title'];
$time = $row2['time'];
$comments = $row2['comments'];
$counter = $row2['counter'];
$topic = $row2['topic'];
$informant = $row2['informant'];
$score = $row2['score'];
$ratings = $row2['ratings'];
$r_options = "";
if (isset($cookie[4])) { $r_options .= "&mode=$cookie[4]"; }
if (isset($cookie[5])) { $r_options .= "&order=$cookie[5]"; }
if (isset($cookie[6])) { $r_options .= "&thold=$cookie[6]"; }
$Y = substr($time, 0, 4);
$M = substr($time, 5, 2);
$D = substr($time, 8, 2);
// Date (D=day, M=month, Y=year) - can be changed to other format such as $M.".".$D.",".$Y;
$time = $Y.".".$M.".".$D;
// Cut the long title to avoid stretch on the table.
// The value '35' is the lenght of the text.
// You may change it to suit your theme. Default is 35.
$title = cut($title,35);
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n"
."<tr><td>\n"
."<table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"100%\">\n"
."<tr height=20 onmouseover=\"this.style.backgroundColor='#eeeeee'\" onmouseout=\"this.style.backgroundColor=''\">\n"
// News titles begin from here
."<td align=\"left\"> <strong><big>·</big></strong>"
." <a href=\"modules.php?name=News&file=article&sid=".$s_sid."".$r_options."\">".$title."</a></td>\n"
// Here you can add more info of the news at the ($comments comments)
// such as ($counter reads) or (Informant: $informant) or (Score: $score).
."<td align=\"right\">(".$comments." comments) ".$time." </td>\n"
."</tr></table></td></tr></table>\n"
."<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" align=\"center\">\n"
."<tr>\n"
."<td height=1 background=\"modules/Mozaks_News/img/dot.gif\"></td>\n"
."</tr>\n"
."</table>\n";
}
CloseTable();
}
echo "<BR>";
}
echo $copy;
include("footer.php");
}
switch ($op) {
default:
index();
break;
}
?>
Hast Du das Modul kompl. installiert (...Mozaks_News&file=install&action=add)
Anschließend mal im admin-Menü im Topics-Manager die entspr. Änderungen/Einstellungen (List this topic at home(Mozaks News) durchgeführt ?
MfG
Ich danke dir, es hat funktioniert :)