Merhaba arkadaşlar, aşağıdaki resimde gördüğünüz gibi, haber kategorilerinde her kategoriden 5 tane çıkıyo, bunları
her kategoride en fazla 3 haber çıkacak şekilde nasıl ayarlarım, kodlar aşağıda..
Not: Kendim yapayı denedim ama malesef olmadı, limitlerle oynadım...

<?php
/*
+--------------------------------------------------------------------------
| MkPortal
| ========================================
| by Meo aka Luponero <Amedeo de longis>
| Don K. Colburn <visiblesoul.net>
|
| Copyright (c) 2004-2007 mkportal.it
| http://www.mkportal.it
| Email: luponero@mclink.it
|
+---------------------------------------------------------------------------
|
| > MKPortal
| > Written By Amedeo de longis
| > Date started: 9.2.2004
|
+--------------------------------------------------------------------------
|
| > Kategorili Haberler Blogu Yapimci Bilgisi
| > Burak ÞÝMÞEK (Burajan)
| > http://www.buraksimsek.net
| > http://www.uzmanweb.net
| >Yayin Tarihi: 07 Temmuz 2008 Pazartesi
|
+--------------------------------------------------------------------------
*/
if (!defined("IN_MKP")) {
die ("Sorry !! You cannot access this file directly.");
}
$limit = $this->config['news_block'];
if (!$limit) {
$limit = 5;
}
// Her yeni kategori için bir cont atamasi yapiyoruz.
// Eger yeni bir kategori blogu eklemek istiyorsaniz bu asagidaki cont degerinden bir tane daha ekleyin ve sayisini belirtin.
// Örnek: $cont10 = "";
$cont = "";
$cont2 = "";
$cont3 = "";
$cont4 = "";
$cont5 = "";
$cont6 = "";
$content = "";
$link_user = $mklib_board->forum_link("profile");
// Bir kategorinin haberlerini aliyoruz. Kategori id degerini idcategoria = '1' bölümünde tanimlayiniz.
// Eger yeni bir kategori blogu eklemek istiyorsaniz bu asagidaki kodlarin bir kopyasini aliniz ve alt satirina yapistiriniz.
// Þuan için asagida 6 tane kategori için tanimlama yapilmistir. Örnegine bakarak sizde yeni bir tane olusturabilirsiniz.
$query = $DB->query( "SELECT n.id, n.idcategoria, n.idautore, n.titolo, n.autore, n.testo, n.data, n.totalcomm, s.id AS idcat, s.titolo AS titcat, s.icona
FROM mkp_news AS n
LEFT JOIN mkp_news_sections AS s ON(s.id = n.idcategoria)
WHERE validate = '1' and idcategoria = '7' ORDER BY `id` DESC LIMIT 5");
while( $row = $DB->fetch_row($query) ) {
$idnt = $row['id'];
$totcomments = $row['totalcomm'];
$id_orig_name = $row['idautore'];
$idcategoria = $row['idcategoria'];
$titolo = stripslashes($row['titolo']);
$name = $row['autore'];
$testo = stripslashes($row['testo']);
if ($this->mkeditor == "BBCODE") {
$testo = $this->decode_bb($testo);
$testo = $mklib_board->decode_smilies($testo);
}
// Bölüm adini tanimliyoruz.
// Buradaki $sezione belirtilen degerde eger yani bir kategori olusturuyorsaniz farkli bir deger vermelisiniz.
// Örnek: $sezione10 = $row['titcat'];
$sezione = $row['titcat'];
$icona = $row['icona'];
switch($icona) {
case '1':
$image = "$this->images/icona_news.gif";
break;
case '2':
$image = "$this->images/icona_help.gif";
break;
case '3':
$image = "$this->images/icona_star.gif";
break;
case '4':
$image = "$this->images/icona_pc.gif";
break;
case '5':
$image = "$this->images/icona_world.gif";
break;
default:
$image = $icona;
break;
}
$cdata = $this->create_date($row['data']);
$news_words= $this->config['news_words'];
if ($this->config['news_html']) {
$testo = str_replace ("
", " ", $testo);
$testo = strip_tags ($testo);
}
if ($news_words) {
$testo = substr ($testo, 0, $news_words);
$testo .= " ...";
}
$cont .= "
- <a href=\"index.php?ind=news&op=news_show_single&ide={$row['id']}\">$titolo
[/url]
";
}
// Bir kategorinin haberlerini aliyoruz. Kategori id degerini idcategoria = '2' bölümünde tanimlayiniz.
$query = $DB->query( "SELECT n.id, n.idcategoria, n.idautore, n.titolo, n.autore, n.testo, n.data, n.totalcomm, s.id AS idcat, s.titolo AS titcat, s.icona
FROM mkp_news AS n
LEFT JOIN mkp_news_sections AS s ON(s.id = n.idcategoria)
WHERE validate = '1' and idcategoria = '2' ORDER BY `id` DESC LIMIT 5");
while( $row = $DB->fetch_row($query) ) {
$idnt = $row['id'];
$totcomments = $row['totalcomm'];
$id_orig_name = $row['idautore'];
$idcategoria = $row['idcategoria'];
$titolo = stripslashes($row['titolo']);
$name = $row['autore'];
$testo = stripslashes($row['testo']);
if ($this->mkeditor == "BBCODE") {
$testo = $this->decode_bb($testo);
$testo = $mklib_board->decode_smilies($testo);
}
// Bölüm adini tanimliyoruz.
$sezione2 = $row['titcat'];
$icona = $row['icona'];
switch($icona) {
case '1':
$image = "$this->images/icona_news.gif";
break;
case '2':
$image = "$this->images/icona_help.gif";
break;
case '3':
$image = "$this->images/icona_star.gif";
break;
case '4':
$image = "$this->images/icona_pc.gif";
break;
case '5':
$image = "$this->images/icona_world.gif";
break;
default:
$image = $icona;
break;
}
$cdata = $this->create_date($row['data']);
$news_words= $this->config['news_words'];
if ($this->config['news_html']) {
$testo = str_replace ("
", " ", $testo);
$testo = strip_tags ($testo);
}
if ($news_words) {
$testo = substr ($testo, 0, $news_words);
$testo .= " ...";
}
$cont2 .= "
- <a href=\"index.php?ind=news&op=news_show_single&ide={$row['id']}\">$titolo
[/url]
";
}
// Bir kategorinin haberlerini aliyoruz. Kategori id degerini idcategoria = '3' bölümünde tanimlayiniz.
$query = $DB->query( "SELECT n.id, n.idcategoria, n.idautore, n.titolo, n.autore, n.testo, n.data, n.totalcomm, s.id AS idcat, s.titolo AS titcat, s.icona
FROM mkp_news AS n
LEFT JOIN mkp_news_sections AS s ON(s.id = n.idcategoria)
WHERE validate = '1' and idcategoria = '3' ORDER BY `id` DESC LIMIT 5");
while( $row = $DB->fetch_row($query) ) {
$idnt = $row['id'];
$totcomments = $row['totalcomm'];
$id_orig_name = $row['idautore'];
$idcategoria = $row['idcategoria'];
$titolo = stripslashes($row['titolo']);
$name = $row['autore'];
$testo = stripslashes($row['testo']);
if ($this->mkeditor == "BBCODE") {
$testo = $this->decode_bb($testo);
$testo = $mklib_board->decode_smilies($testo);
}
// Bölüm adini tanimliyoruz.
$sezione3 = $row['titcat'];
$icona = $row['icona'];
switch($icona) {
case '1':
$image = "$this->images/icona_news.gif";
break;
case '2':
$image = "$this->images/icona_help.gif";
break;
case '3':
$image = "$this->images/icona_star.gif";
break;
case '4':
$image = "$this->images/icona_pc.gif";
break;
case '5':
$image = "$this->images/icona_world.gif";
break;
default:
$image = $icona;
break;
}
$cdata = $this->create_date($row['data']);
$news_words= $this->config['news_words'];
if ($this->config['news_html']) {
$testo = str_replace ("
", " ", $testo);
$testo = strip_tags ($testo);
}
if ($news_words) {
$testo = substr ($testo, 0, $news_words);
$testo .= " ...";
}
$cont3 .= "
- <a href=\"index.php?ind=news&op=news_show_single&ide={$row['id']}\">$titolo
[/url]
";
}
// Bir kategorinin haberlerini aliyoruz. Kategori id degerini idcategoria = '4' bölümünde tanimlayiniz.
$query = $DB->query( "SELECT n.id, n.idcategoria, n.idautore, n.titolo, n.autore, n.testo, n.data, n.totalcomm, s.id AS idcat, s.titolo AS titcat, s.icona
FROM mkp_news AS n
LEFT JOIN mkp_news_sections AS s ON(s.id = n.idcategoria)
WHERE validate = '1' and idcategoria = '4' ORDER BY `id` DESC LIMIT 5");
while( $row = $DB->fetch_row($query) ) {
$idnt = $row['id'];
$totcomments = $row['totalcomm'];
$id_orig_name = $row['idautore'];
$idcategoria = $row['idcategoria'];
$titolo = stripslashes($row['titolo']);
$name = $row['autore'];
$testo = stripslashes($row['testo']);
if ($this->mkeditor == "BBCODE") {
$testo = $this->decode_bb($testo);
$testo = $mklib_board->decode_smilies($testo);
}
// Bölüm adini tanimliyoruz.
$sezione4 = $row['titcat'];
$icona = $row['icona'];
switch($icona) {
case '1':
$image = "$this->images/icona_news.gif";
break;
case '2':
$image = "$this->images/icona_help.gif";
break;
case '3':
$image = "$this->images/icona_star.gif";
break;
case '4':
$image = "$this->images/icona_pc.gif";
break;
case '5':
$image = "$this->images/icona_world.gif";
break;
default:
$image = $icona;
break;
}
$cdata = $this->create_date($row['data']);
$news_words= $this->config['news_words'];
if ($this->config['news_html']) {
$testo = str_replace ("
", " ", $testo);
$testo = strip_tags ($testo);
}
if ($news_words) {
$testo = substr ($testo, 0, $news_words);
$testo .= " ...";
}
$cont4 .= "
- <a href=\"index.php?ind=news&op=news_show_single&ide={$row['id']}\">$titolo
[/url]
";
}
// Bir kategorinin haberlerini aliyoruz. Kategori id degerini idcategoria = '5' bölümünde tanimlayiniz.
$query = $DB->query( "SELECT n.id, n.idcategoria, n.idautore, n.titolo, n.autore, n.testo, n.data, n.totalcomm, s.id AS idcat, s.titolo AS titcat, s.icona
FROM mkp_news AS n
LEFT JOIN mkp_news_sections AS s ON(s.id = n.idcategoria)
WHERE validate = '1' and idcategoria = '5' ORDER BY `id` DESC LIMIT 5");
while( $row = $DB->fetch_row($query) ) {
$idnt = $row['id'];
$totcomments = $row['totalcomm'];
$id_orig_name = $row['idautore'];
$idcategoria = $row['idcategoria'];
$titolo = stripslashes($row['titolo']);
$name = $row['autore'];
$testo = stripslashes($row['testo']);
if ($this->mkeditor == "BBCODE") {
$testo = $this->decode_bb($testo);
$testo = $mklib_board->decode_smilies($testo);
}
// Bölüm adini tanimliyoruz.
$sezione5 = $row['titcat'];
$icona = $row['icona'];
switch($icona) {
case '1':
$image = "$this->images/icona_news.gif";
break;
case '2':
$image = "$this->images/icona_help.gif";
break;
case '3':
$image = "$this->images/icona_star.gif";
break;
case '4':
$image = "$this->images/icona_pc.gif";
break;
case '5':
$image = "$this->images/icona_world.gif";
break;
default:
$image = $icona;
break;
}
$cdata = $this->create_date($row['data']);
$news_words= $this->config['news_words'];
if ($this->config['news_html']) {
$testo = str_replace ("
", " ", $testo);
$testo = strip_tags ($testo);
}
if ($news_words) {
$testo = substr ($testo, 0, $news_words);
$testo .= " ...";
}
$cont5 .= "
- <a href=\"index.php?ind=news&op=news_show_single&ide={$row['id']}\">$titolo
[/url]
";
}
// Bir kategorinin haberlerini aliyoruz. Kategori id degerini idcategoria = '6' bölümünde tanimlayiniz.
$query = $DB->query( "SELECT n.id, n.idcategoria, n.idautore, n.titolo, n.autore, n.testo, n.data, n.totalcomm, s.id AS idcat, s.titolo AS titcat, s.icona
FROM mkp_news AS n
LEFT JOIN mkp_news_sections AS s ON(s.id = n.idcategoria)
WHERE validate = '1' and idcategoria = '6' ORDER BY `id` DESC LIMIT 5");
while( $row = $DB->fetch_row($query) ) {
$idnt = $row['id'];
$totcomments = $row['totalcomm'];
$id_orig_name = $row['idautore'];
$idcategoria = $row['idcategoria'];
$titolo = stripslashes($row['titolo']);
$name = $row['autore'];
$testo = stripslashes($row['testo']);
if ($this->mkeditor == "BBCODE") {
$testo = $this->decode_bb($testo);
$testo = $mklib_board->decode_smilies($testo);
}
// Bölüm adini tanimliyoruz.
$sezione6 = $row['titcat'];
$icona = $row['icona'];
switch($icona) {
case '1':
$image = "$this->images/icona_news.gif";
break;
case '2':
$image = "$this->images/icona_help.gif";
break;
case '3':
$image = "$this->images/icona_star.gif";
break;
case '4':
$image = "$this->images/icona_pc.gif";
break;
case '5':
$image = "$this->images/icona_world.gif";
break;
default:
$image = $icona;
break;
}
$cdata = $this->create_date($row['data']);
$news_words= $this->config['news_words'];
if ($this->config['news_html']) {
$testo = str_replace ("
", " ", $testo);
$testo = strip_tags ($testo);
}
if ($news_words) {
$testo = substr ($testo, 0, $news_words);
$testo .= " ...";
}
$cont6 .= "
- <a href=\"index.php?ind=news&op=news_show_single&ide={$row['id']}\">$titolo
[/url]
";
}
// Her kategoriyi asagidaki alanda gösteriyoruz.
// Burada biraz html bilgisi gerekiyor. Örnegine bakarak yapabilirsiniz.
// Eger yeni bir kategori olusturduysaniz bölüm adini $sezione ve {$cont} tanimlamasini yapmalisiniz.
// Örnek: $sezione10 ve {$cont10}
$content = "
<tr>
<td class=\"contents\">
<div class=\"taburlo\">
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">
<tr>
<td class=\"taburlo\" valign=\"top\">
<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">
<tr>
<td valign=\"top\" width=\"50%\">
<table class=\"tabnews\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">
<tbody>
<tr>
<td class=\"tdblock\" valign=\"top\" width=\"95%\">
$sezione
</td>
</tr>
<tr>
<td colspan=\"2\">
{$cont}
</td>
</tr>
</tbody>
</table>
</td>
<td valign=\"top\" width=\"50%\">
<table class=\"tabnews\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">
<tbody>
<tr>
<td class=\"tdblock\" valign=\"top\" width=\"95%\">
$sezione2
</td>
</tr>
<tr>
<td colspan=\"2\">
{$cont2}
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td valign=\"top\" width=\"50%\">
<table class=\"tabnews\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">
<tbody>
<tr>
<td class=\"tdblock\" valign=\"top\" width=\"95%\">
$sezione3
</td>
</tr>
<tr>
<td colspan=\"2\">
{$cont3}
</td>
</tr>
</tbody>
</table>
</td>
<td valign=\"top\" width=\"50%\">
<table class=\"tabnews\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">
<tbody>
<tr>
<td class=\"tdblock\" valign=\"top\" width=\"95%\">
$sezione4
</td>
</tr>
<tr>
<td colspan=\"2\">
{$cont4}
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td valign=\"top\" width=\"50%\">
<table class=\"tabnews\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">
<tbody>
<tr>
<td class=\"tdblock\" valign=\"top\" width=\"95%\">
$sezione5
</td>
</tr>
<tr>
<td colspan=\"2\">
{$cont5}
</td>
</tr>
</tbody>
</table>
</td>
<td valign=\"top\" width=\"50%\">
<table class=\"tabnews\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">
<tbody>
<tr>
<td class=\"tdblock\" valign=\"top\" width=\"95%\">
$sezione6
</td>
</tr>
<tr>
<td colspan=\"2\">
{$cont6}
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
";
unset($cont);
unset($row);
unset($idcat);
unset($categoria);
unset($idnt);
unset($query);
unset($query2);
unset($totcomments);
unset($id_orig_name);
unset($idcategoria);
unset($titolo);
unset($name);
unset($testo);
unset($sezione);
unset($icona);
unset($cdata);
unset($news_words);
?>