Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks
Author Message
Savent
Regular
Regular


Joined: Jun 30, 2003
Posts: 81

PostPosted: Mon Dec 13, 2004 1:48 am Reply with quote

Hi all, I need some help editing old articles block, I would like for it too show like the last 5 days news was posted, everytime I post news, that block grows and grows, Is there a way to make it show only a certain number of days, here is the code of my block, Thank-you for your time:)

<?php

/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2002 by Francisco Burzi */
/* Only registered users can see links on this board! Get registered or login! */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
/* Additional security & Abstraction layer conversion */
/* 2003 chatserv */
/* Only registered users can see links on this board! Get registered or login! -- Only registered users can see links on this board! Get registered or login! */
/************************************************************************/

if (eregi("block-Old_Articles.php", $_SERVER['SCRIPT_NAME'])) {
Header("Location: index.php");
die();
}

global $locale, $oldnum, $storynum, $storyhome, $cookie, $categories, $cat, $prefix, $multilingual, $currentlang, $db, $new_topic, $user_news;

if ($multilingual == 1) {
if ($categories == 1) {
$querylang = "where catid='$cat' AND (alanguage='$currentlang' OR alanguage='')";
} else {
$querylang = "where (alanguage='$currentlang' OR alanguage='')";
if ($new_topic != 0) {
$querylang .= " AND topic='$new_topic'";
}
}
} else {
if ($categories == 1) {
$querylang = "where catid='$cat'";
} else {
$querylang = "";
if ($new_topic != 0) {
$querylang = "WHERE topic='$new_topic'";
}
}
}
if (isset($cookie[3]) AND $user_news == 1) {
$storynum = $cookie[3];
} else {
$storynum = $storyhome;
}
$boxstuff = "<table border=\"0\" width=\"100%\">";
$boxTitle = _PASTARTICLES;
$result = $db->sql_query("SELECT sid, title, time, comments FROM ".$prefix."_stories $querylang ORDER BY time DESC LIMIT $storynum, $oldnum");
$vari = 0;

$r_options = "";
if (isset($cookie[4])) { $r_options .= "&amp;mode=$cookie[4]"; }
if (isset($cookie[5])) { $r_options .= "&amp;order=$cookie[5]"; }
if (isset($cookie[6])) { $r_options .= "&amp;thold=$cookie[6]"; }

while ($row = $db->sql_fetchrow($result)) {
$sid = intval($row['sid']);
$title = stripslashes($row['title']);
$time = $row['time'];
$comments = $row['comments'];
$see = 1;
setlocale(LC_TIME, $locale);
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2})Sad[0-9]{1,2})Sad[0-9]{1,2})", $time, $datetime2);
$datetime2 = strftime(""._DATESTRING2."", mktime($datetime2[4],$datetime2[5],$datetime2[6],$datetime2[2],$datetime2[3],$datetime2[1]));
$datetime2 = ucfirst($datetime2);
if ($articlecomm == 1) {
$comments = "($comments)";
} else {
$comments = "";
}
if($time2==$datetime2) {
$boxstuff .= "<tr><td valign=\"top\"><strong><big>&middot;</big></strong></td><td> <a href=\"modules.php?name=News&amp;file=article&amp;sid=$sid$r_options\">$title</a> $comments</td></tr>\n";
} else {
if($a=="") {
$boxstuff .= "<tr><td colspan=\"2\"><b>$datetime2</b></td></tr><tr><td valign=\"top\"><strong><big>&middot;</big></strong></td><td> <a href=\"modules.php?name=News&amp;file=article&amp;sid=$sid$r_options\">$title</a> $comments</td></tr>\n";
$time2 = $datetime2;
$a = 1;
} else {
$boxstuff .= "<tr><td colspan=\"2\"><b>$datetime2</b></td></tr><tr><td valign=\"top\"><strong><big>&middot;</big></strong></td><td> <a href=\"modules.php?name=News&amp;file=article&amp;sid=$sid$r_options\">$title</a> $comments</td></tr>\n";
$time2 = $datetime2;
}
}
$vari++;
if ($vari==$oldnum) {
if (isset($cookie[3])) {
$storynum = $cookie[3];
} else {
$storynum = $storyhome;
}
$min = $oldnum + $storynum;
$dummy = 1;
}
}

if ($dummy == 1 AND is_active(Stories_Archive)) {
$boxstuff .= "</table><br><a href=\"archive.html\"><b>"._OLDERARTICLES."</b></a>\n";
} else {
$boxstuff .= "</table>";
}

if ($see == 1) {
$content = $boxstuff;
}
$content .= "<br><center>[ <a href=\"news.html\">"._MORENEWS."</a> ]</center>";

?>

_________________
Only registered users can see links on this board! Get registered or login! [Online Arcade 340+ Games]
Image 
View user's profile Send private message Send e-mail Visit poster's website
Nukeum66
Life Cycles Becoming CPU Cycles


Joined: Jul 30, 2003
Posts: 551
Location: Neurotic, State, USA

PostPosted: Mon Dec 13, 2004 4:50 am Reply with quote

Change this line:
Code:
$result = $db->sql_query("SELECT sid, title, time, comments FROM ".$prefix."_stories $querylang ORDER BY time DESC LIMIT $storynum, $oldnum"); 


To This:
Code:
$result = $db->sql_query("SELECT sid, title, time, comments FROM ".$prefix."_stories $querylang ORDER BY time DESC LIMIT 0,5"); 

_________________
Scott Johnson MIS Ubuntu/Linux 11.10 
View user's profile Send private message Visit poster's website
Savent
PostPosted: Mon Dec 13, 2004 10:51 am Reply with quote

Thanks man it worked Smile
 
Nukeum66
PostPosted: Mon Dec 13, 2004 5:20 pm Reply with quote

Wink
 
oprime2001
Worker
Worker


Joined: Jun 04, 2004
Posts: 119
Location: Chicago IL USA

PostPosted: Mon Dec 13, 2004 7:44 pm Reply with quote

If you want less than 10 articles in the block, you will have to edit the code -- such as per Nukeum66 instructions.

But if 10 articles in the block is ok, as an alternative to editing the code, you can also limit the number of articles in the Old Articles block via the admin pages. Specifically, there is an Stories in Old Articles Box: option within Web Site Configuration / Preferences [ example.com/admin.php?op=Configure ].
 
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks

View next topic
View previous topic
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
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©