Gönderen Konu: Haber Kategorileri (Kategori news) değişiklik  (Okunma sayısı 1105 defa)

0 Üye ve 1 Ziyaretçi konuyu incelemekte.

Çevrimdışı baypipox

  • İleti: 75
  • Puan: 0
Haber Kategorileri (Kategori news) değişiklik
« : Şubat 05, 2009, 04:52:59 ÖÖ »
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...



Alıntı
<?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&amp;op=news_show_single&amp;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&amp;op=news_show_single&amp;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&amp;op=news_show_single&amp;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&amp;op=news_show_single&amp;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&amp;op=news_show_single&amp;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&amp;op=news_show_single&amp;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);

?>
« Son Düzenleme: Şubat 05, 2009, 04:54:45 ÖÖ Gönderen: baypipox »
Konuyu Paylaş:
  delicious  facebook  twitter  google

Çevrimdışı coruhunsesi

  • Süper Moderatör
  • *
  • İleti: 572
  • Puan: 24
  • Cinsiyet: Bay
  • Php de adım adım yol alıyor'du
-Haber Kategorileri (Kategori news) değişiklik
« Yanıtla #1 : Şubat 05, 2009, 07:48:17 ÖÖ »
Hocam kodun en üstünde $limit = 5;  burayla hiç oynadınmı denerken burayı 3 yap ve öyle dene sanırım sorun çözülür. kolay gelsin
Bir bak etrafına herkes mutlu bir sen misin üzgün? Dertler türlü türlü her biri bir sürgün!Ama unutma ki ALLAH var gülsün yüzün.

Çevrimdışı baypipox

  • İleti: 75
  • Puan: 0
-Haber Kategorileri (Kategori news) değişiklik
« Yanıtla #2 : Şubat 05, 2009, 08:44:30 ÖÖ »
İbrahim hocam ben normalde ilk onu denemiştim fakat, ayrıyetten bide sql'lerdeki limit'i 3 yapmak gerekiyomuş,
gerçi ben onlarıda yapmıştım ama olmamıştı, sabahın ilk ışıklarıyla yapınca oldu  :D :D

ilgin için teşekkür ederim..

Çevrimdışı AcemiXoops

  • İleti: 102
  • Puan: 0
-Haber Kategorileri (Kategori news) değişiklik
« Yanıtla #3 : Şubat 12, 2009, 00:14:41 ÖÖ »
İbrahim hocam ben normalde ilk onu denemiştim fakat, ayrıyetten bide sql'lerdeki limit'i 3 yapmak gerekiyomuş,
gerçi ben onlarıda yapmıştım ama olmamıştı, sabahın ilk ışıklarıyla yapınca oldu  :D :D

ilgin için teşekkür ederim..
Bence insanlarin kafasini karistirmanin hic geregi yok dostum. sql falan uzun hikaye?

ORDER BY `id` DESC LIMIT 5yukaridaki kodlarda bublari bulup 5 i 3 veya istedigin sayiyi verebilirsin..
« Son Düzenleme: Şubat 13, 2009, 00:54:42 ÖÖ Gönderen: AcemiXoops »

 

Benzer Konular

  Konu / Başlatan Yanıt Son İleti
0 Yanıt
1731 Gösterim
Son İleti Nisan 18, 2007, 09:26:01 ÖÖ
Gönderen: bilgicagi
0 Yanıt
1026 Gösterim
Son İleti Mayıs 31, 2008, 22:24:13 ÖS
Gönderen: keyifadami
31 Yanıt
7497 Gösterim
Son İleti Mayıs 29, 2011, 19:08:00 ÖS
Gönderen: mert_om
2 Yanıt
895 Gösterim
Son İleti Temmuz 09, 2009, 00:57:57 ÖÖ
Gönderen: nastyfighter
5 Yanıt
1026 Gösterim
Son İleti Eylül 11, 2009, 23:25:19 ÖS
Gönderen: AdmiN