PDA

View Full Version : Show "Latest News" in two (or more) columns


boccio
06-16-2006, 01:32 PM
In HTML_function.php file find the HTML_latest_news() function (somwhere around line 1477) and replace it with new function below. Adjust $col_no parameter at the beginning of the code to match the number of columns you wish to have.


function HTML_latest_news($featured=0){

// custom number of columns for Latest Articles section
$col_no = 2; // put the desired number of columns here

global $url, $tpl_folder, $showFriendlyURL, $lang, $cur_date;
global $latest_news_number, $latest_news_title,
$latest_news_image_width, $latest_news_word_number;
global $headlines_number, $headlines_title,
$headlines_image_width, $headlines_word_number;
global $article, $rule, $show_date, $show_author;

if ($latest_news_title=="" or $language<>'')
$latest_news_title=$lang['LNG_LATEST_NEWS'];
if ($headlines_number=='')
$headlines_number=1;
if ($headlines_title=='' or $language<>'')
$headlines_title=$lang['LNG_FEATURED_NEWS'];
if ($featured==1){
$news_title=$headlines_title;
$news_number=$headlines_number;
$news_image_width=$headlines_image_width;
$news_word_number=$headlines_word_number;
} else {
$news_title=$latest_news_title;
$news_number=$latest_news_number;
$news_image_width=$latest_news_image_width;
$news_word_number=$latest_news_word_number;
}
if ($news_number=='') $news_number=3;
if ($news_image_width<1) $news_image_width=200;

$cur_col = 0;

$latest_news_HTML = "<h1>$news_title</h1>";
$latest_news_HTML.= '<table width="100%">';

$query="SELECT id FROM tblArticles
WHERE status=1
AND featured_news=$featured
AND created<='$cur_date'
ORDER BY order_num DESC LIMIT {$news_number}";
$result_main=mysql_query($query) or sql_error($query,"HTML_latest_news");

while ($row=mysql_fetch_array($result_main)){
$cur_col++;
if ($cur_col>1){
$latest_news_HTML.= '<td valign="top">';
} else {
$latest_news_HTML.= '<tr><td valign="top">';
}
$article=new Article();
$article->LoadFromDatebase($connection,$row['id']);
// Show date
$article_date=Show_Date();
// Show author
$article_author=Show_Author();

$Breadcrumb_HTML=HTML_Article_Breadcrumb();
$Caption_Title=HTML_Caption_Title();
$body = HTML_Article_Short($news_word_number);
$body.= HTML_Article_Link();
$show_author_link_HTML="";
if ($article->Type=='1') {
$times_read="";
$lang_times_read="";
} else {
$times_read=$article->Times_read;
$lang_times_read=$lang['LNG_TIMES_READ'];
}

$article_comment_number_HTML=HTML_article_comment_ number();

if ($article->Type=='1' or $article->Times_read=="0"){
$times_read="";
$lang_times_read="";
$num_posted=' ';
} else {
$times_read=$article->Times_read;
$lang_times_read=$lang['LNG_TIMES_READ'];
}
if ($article->Image == "" or !file_exists($root."files/".$article->Image))
$article->Image = "spacer.gif";
$vp_size = getimagesize("files/".$article->Image);
$vp_width = min($news_image_width,$vp_size[0]);
$article->Image.='" width="'.$vp_width;

$filename="$tpl_folder/article_Short.tpl";
$subject=file_get_contents($filename);
$pattern=array('{ROOT}',
'{ID}',
'{AUTHOR}',
'{CREATED}',
'{BREADCRUMBS}',
'{CAPTION_TITLE}',
'{BODY}',
'{TIMES READ}',
'{NUM_POSTED}',
'{SHOW_AUTHOR_LINK}',
'{LNG_TIMES_READ}',
'{IMAGE}'
);
$replacement=array($url,
$article->Id,
$article_author,
$article_date,
$Breadcrumb_HTML,
$Caption_Title,
$body,
$times_read,
$article_comment_number_HTML,
$show_author_link,
$lang_times_read,
$article->Image
);
$latest_news_HTML.=my_str_replace($pattern, $replacement, $subject);
if ($cur_col==$col_no){
$latest_news_HTML.= '</td></tr>';
$cur_col = 0;
} else {
$latest_news_HTML.= '</td>';
}
}
$latest_news_HTML.= '</table>';

return $latest_news_HTML;
}

Frankc
06-16-2006, 02:11 PM
It works very nice thank you guys.

I just changed the following so that the 2 columns have the same wide.


$latest_news_HTML.= '<td valign="top" width="333">';
} else {
$latest_news_HTML.= '<tr><td valign="top" width="333">';

ColorBoxes
06-16-2006, 05:34 PM
its realy very nice ..

i already do this ,,, www.ismailawy.net/test
but i want to do latest news in headline with marquee ..i tried to do but i can't .. pleas answer me in littel wordes... :)