Ik wil mijn Last 5 articles block aanpassen.
Ik heb daarvoor een module gevonden, maar dan is het om één of andere reden niet meer mogelijk om topics te maken voor de nieuwsberichten.
Ik had vervolgens de gedachten om het module om te zetten in een block.
Nu is mijn vraag, welke regels moet ik eruit halen om het block te laten werken.
Had de verwijzingen naar mainfile, footer, header e.d al weggehaald, maar misschien moet er nog meer weg.
Of misschien werkt het gewoon niet en moet ik het last 5 articles block aanpassen naar de wensen die ik heb.
Code:
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");
$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 "<center><img></center><br>";
echo "<table>\n"
."<tr>\n"
// Topics
//."<td><B>:: $topictext</B></td>\n"
// Link to topic
//."<td> <a>meer ...</a> </td>\n"
."</tr>\n"
."</table>\n";
// Bold line below topic title
echo "<table>\n"
."<tr>\n"
// Topic line's color. You could change the color code to suit your theme
//."<td><img></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 = $D."-".$M."-".$Y;
// 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,150);
echo "<table>\n"
."<tr><td>\n"
."<table>\n"
//."<tr>\n"
// News titles begin from here
."<td></td>\n"
."<td> <strong><big>·</big></strong>"
." <a>$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> $time </td>\n"
."<td></td>\n"
."</tr></table></td></tr></table>\n"
."<table>\n"
."<tr>\n"
."<td></td>\n"
."<td></td>\n"
."<td></td>\n"
."</tr>\n"
."</table>\n";
}
CloseTable();
}
echo "<BR>";
}
echo $copy;
include("footer.php");
}
switch ($op) {
default:
index();
break;
}
?>
bjornju Beginner
Joined: Apr 01, 2008
Posts: 14
Posted:
Mon 12 May 2008 21:33
Met wat knip en plak werk heb ik inmiddels het Last 5 articles block aankunnen passen naar dit;
Code:
if ( !defined('BLOCK_FILE') ) {
Header("Location: ../index.php");
die();
}
global $prefix, $multilingual, $currentlang, $db;
if ($multilingual == 1) {
$querylang = "WHERE (alanguage='$currentlang' OR alanguage='')";
} else {
$querylang = "";
}
$content = "<table>";
$sql = "SELECT sid, title, time, comments, counter FROM ".$prefix."_stories $querylang ORDER BY sid DESC LIMIT 0,5";
$result = $db->sql_query($sql);
while (list($sid, $title, $time, $comments, $counter) = $db->sql_fetchrow($result)) {
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum