30
« on: January 21, 2012, 10:04:58 AM »
Step 12 not work "LIMIT" param... I`ve done some changes with code:
In step 12 search in root/index.php:
//############################################## Start News ###########################################################
$sql = "SELECT news_id, news_title, news_text, user_name, news_date
FROM ".NEWS_TABLE."
ORDER BY news_date DESC
LIMIT 1
";
$result = $site_db->query($sql);
$news_row = $site_db->fetch_array($result);
if (!$news_row){
$news_text = $lang['no_news']." <a href=\"".$site_sess->url(ROOT_PATH."news.php")."\" >".$lang['news_archive']."</a>";
$site_template->register_vars(array(
"lang_news_main" => $lang['news_main'],
"news_text" => format_text($news_text, $config['news_html'], 0, $config['news_bbcode'], $config['news_bbcodeimg']),
));
}
else {
$admin_links = "";
if ($user_info['user_level'] == ADMIN){
$admin_links_add = "<a class=\"smalltext\" href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("news.php?action=addnews"))."\" >".$lang['add']."</a> ";
$admin_links .= "<a style=\"font-size:10px;color:silver\" href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("news.php?action=editnews&news_id=".$news_row['news_id']))."\">".$lang['edit']."</a> ";
$admin_links .= "<a style=\"font-size:10px;color:silver\" href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("news.php?action=removenews&news_id=".$news_row['news_id']))."\">".$lang['delete']."</a>";
}
$news_text = str_replace("/>", ">",$news_row['news_text']);
$new_is_new = ($news_row['news_date'] > time() - ((isset($config['news_isnew']))? $config['news_isnew']:3)*86400);
$site_template->register_vars(array(
"lang_news_main" => $lang['news_main']." -- ",
"news_title" => "<b>".$news_row['news_title']."</b>".(($new_is_new)?" <sup class=\"new\">".$lang['new']."</sup>":"")."</span>",
"news_date" => "<b><span class=\"smalltext\">". format_date($config['date_format']." ".$config['time_format'], $news_row['news_date'])."</span>",
"news_text" => format_text($news_text, $config['news_html'], 0, $config['news_bbcode'], $config['news_bbcodeimg'])." <br><br><a class=\"smalltext\" href=\"".$site_sess->url(ROOT_PATH."news.php")."\" > ".$lang['news_archive']."</a>",
"admin_links" => $admin_links,
"admin_links_add" => ($admin_links_add) ? $admin_links_add:"",
"news_id" => $news_row['news_id']
));
}
//#################################################### End News ###################################################
Then replace this:
//############################################## Start News ###########################################################
$news_text = "";
$num_news = 4;
$sql = "SELECT news_id, news_title, news_text, user_name, news_date
FROM ".NEWS_TABLE."
ORDER BY news_date DESC
LIMIT $num_news";
$result = $site_db->query($sql);
$news_row = $site_db->get_numrows($result);
while ($news_row = $site_db->fetch_array($result)){
$news_date = (isset($news_row['news_date'])) ? format_date($config['date_format'], $news_row['news_date']) : REPLACE_EMPTY;
$new_is_new = ($news_row['news_date'] > time() - ((isset($config['news_isnew']))? $config['news_isnew']:3)*86400);
$news_text .= "<table border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
$news_text .= "<td align=\"left\">";
$news_text .= "<b><span class=\"smalltext\">".$news_date."</span> | <b> ".$news_row['news_title']."</b>".(($new_is_new)?" <sup class=\"smalltext\"><font color=\"#f6f16e\"> (".$lang['new'].")</font></sup>":"")."</span>";
$news_text .= "</td>";
$news_text .= "</tr>";
$news_text .= "</table>";
}
$site_template->register_vars("news_text", $news_text);
unset($news_text);
//#################################################### End News ###################################################
Change "$num_news = 4" in the code by number how many news do you need!