THIS POST HAS BEEN REPLACE BY THE FIRST ONE IN THIS THREAD.
THE UPDATES WHERE GETTING TO CONFUSING FOR PEOPLE TO FOLLOW SO I'VE RE-DOCUMENTED THE STEPS AND TESTED FULLY. PLEASE GO PACK TO MY FIRST POSTING ON THIS TOPIC TO FOLLOW INSTUCTIONSTHANKS
Fugaziman
The paging Fugaziman????
Okay here's the changes you need to make to my original mod to allow for paging...
To display the Archived News I now use a new template page rather than showing all the new images, categories, in the home.html page each time.
So here's what you need to do...
Step 1
Make a copy of you Index.php file (just in case)
Step 2
Edit the index.php and search for my latest news mod you added
Step 3
Make a note of the variable you set previously especially your Latest News image ID
Step 4
Replace the mod with this ....
//----------------------------------------------------
// Latest and Archive News Mod --
// --
// User configurable variables --
// You must change the first 4 variables to meet --
// your requirements: (see notes below) --
// $display_by_count --
// $latest_news_day --
// $show_news_articles --
// $news_image --
//----------------------------------------------------
$display_by_count = "0"; // values 0 or 1
// Change this to 0 if display by days posted or 1 to display fixed number of news articles as Latest
$latest_news_days = "31"; // Number of days news displays at Latest
// Change This to the number of days news shows as Latest
$show_news_articles = "5"; // Number of news articles to show
// Change This to fixed number of articles to display for latest news
$news_image = *****; // Change This to your Latest news image id
$new_news = (time() - 60 * 60 * 24 * $latest_news_days);
//----------------------------------------------------
if ($newstype == "latestnewsall"){
$news_type = "latestnewsall";
}
else {
$news_type = "latestnews";
}
//-----------------------------------------------------
//---Show Latest News -------------------------------
//-----------------------------------------------------
$additional_sql = "";
if ($news_type == "latestnews") {
if ($display_by_count) {
$additional_sql .= " c.image_id = '".$news_image."'";
$additional_sql_2 .= " LIMIT ".$show_news_articles;
}
else {
$additional_sql .= " c.comment_date > '".$new_news."' AND c.image_id = '".$news_image."'";
$additional_sql_2 .= "";
}
}
else {
$additional_sql .= " c.image_id = '".$news_image."'";
$clickstream = "<a href=\"".$site_sess->url(ROOT_PATH."index.php")."\">".$lang['home']."</a> / Archived News";
}
$sql = "SELECT c.comment_headline, c.comment_text, c.comment_date, c.image_id
FROM ".COMMENTS_TABLE." c
WHERE ".$additional_sql."
ORDER BY c.comment_date DESC" .$additional_sql_2 ;
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
$news_comment_row = array();
while ($row = $site_db->fetch_array($result)) {
$news_comment_row[] = $row;
}
$site_db->free_result($result);
// Paging stuff
if ($newstype == "latestnewsall") {
include(ROOT_PATH.'includes/paging.php');
$perpage = $show_news_articles;
$link_arg = $site_sess->url(ROOT_PATH."index.php?newstype=latestnewsall");
$getpaging = new Paging($page, $perpage, $num_rows, $link_arg);
$offset = $getpaging->get_offset();
$site_template->register_vars(array(
"paging" => $getpaging->get_paging(),
"paging_stats" => $getpaging->get_paging_stats()
));
$sql = "SELECT c.comment_headline, c.comment_text, c.comment_date, c.image_id
FROM ".COMMENTS_TABLE." c
WHERE ".$additional_sql."
ORDER BY c.comment_date DESC" .$additional_sql_2."
LIMIT $offset, $perpage";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
$news_comment_row = array();
while ($row = $site_db->fetch_array($result)) {
$news_comment_row[] = $row;
}
}
//
if (!$num_rows) {
$news_comments = " <b>No New News to report within the last ".$latest_news_days." days.</b>";
}
else {
$news_comments = "";
$bgcounter = 0;
for ($i = 0; $i < $num_rows; $i++) {
$row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
$site_template->register_vars(array(
"news_comment_headline" => format_text($news_comment_row[$i]['comment_headline'], 0, $config['wordwrap_comments'], 0, 0),
"news_comment_text" => format_text($news_comment_row[$i]['comment_text'], $config['html_comments'], $config['wordwrap_comments'], $config['bb_comments'], $config['bb_img_comments']),
"news_comment_date" => format_date($config['date_format']." ".$config['time_format'], $news_comment_row[$i]['comment_date']),
"row_bg_number" => $row_bg_number));
$news_comments .= $site_template->parse_template("news_comment_bit");
}
}
$site_template->register_vars("news_comments", $news_comments);
unset($news_comments);
This uses the $show_news_articles = "5"; variable to set the number of news comments to display at the to of the page. You can change this number to fit in your site.Step 5
Search for
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
"msg" => $msg,
"clickstream" => $clickstream
));
Step 6
Insert this code immediatley after
if ($news_type == "latestnewsall") {
$site_template->print_template($site_template->parse_template(archive));
}
else {
$site_template->print_template($site_template->parse_template($main_template));
}
Step 7
set the variables at the top of this mod especially the $news_image with your Latest News image ID
Step 8
Create a new template page in your templates directory. I suggest making a copy of your home.html file, renaming it archive.html, and removing all the stuff you don't want to display on your news archive page.
Step 9
insert this code where you want the news archive to appear
<table width="100%" border="1" cellspacing="1" cellpadding="1">
<tr>
<td align="left" class="head1" height="20">Archived News</td>
<td align="right" class="head1" height="20">{paging}></td>
</tr>
<tr>
<td colspan="2">
<table width="100%" border="1" cellspacing="1" cellpadding="4">
{news_comments}
</table>
</td>
</tr>
<tr>
<td align="left" class="head1" height="20"> <a href="./index.php">Latest News</a></td>
<td align="right" class="head1" height="20">{paging} </td>
</tr>
</table>
Okay I think that's it.
I had a little trouble posting this update as I kept getting "Unable to connect to database errors but I think it's all here. If you have any problems then let me know and I'll help you.
Good luck
Fugaziman