Membuat Auto looping Blok Kategori Pada Popoji CMS
Jurnalcode.com

Membuat Auto looping Blok Kategori Pada Popoji CMS

Membuat Auto looping Blok Kategori Pada Popoji CMS


Jurnalcode : Pada tulisan kali ini saya akan membahas tentang bagaimana cara membuat Auto looping Blok Kategori Pada Popoji CMS . nah mungkin dari judul kalian sedikit agak kebingungan, Saat ini pada theme Basic Bawaah Popoji yakni chingsy Theme pemanggilan blog kategori di lakukan secara manual, jadi ketika kita menambahkan kategori baru maka kita harus menambahkan code manual untuk menampilkan kategori baru tersebut. ribet kan?? apalagi bagi yang awam dengan coding .. wah pasti bisa pusing 8 keliling.

 

Langkah - Langkah Membuat Auto loop blok  Kategori di Popoji CMS

# VERSI 2.x.x

silahkan Edit home.php , saya ambil contoh theme defaul chingsy code pemanggilan blok kategori manual nya adalah sebagai berikut :

<div class="col_full bottommargin-lg clearfix">
   <?php $category_title = $this->category()->getOneCategory('1', WEB_LANG_ID); ?>
   <div class="fancy-title title-border">
      <h3><?=$category_title['title'];?></h3>
   </div>
   <?php
      $post_by_categorys = $this->post()->getPostByCategory('1', '1', 'DESC', WEB_LANG_ID);
      foreach($post_by_categorys as $list_post){
      ?>
   <div class="ipost clearfix">
      <div class="col_half bottommargin-sm">
         <div class="entry-image"><a href="<?=$this->pocore()->call->postring->permalink(rtrim(BASE_URL, '/'), $list_post);?>"><img class="image_fade" src="<?=BASE_URL;?>/<?=DIR_CON;?>/uploads/medium/medium_<?=$list_post['picture'];?>" alt=""></a></div>
      </div>
      <div class="col_half bottommargin-sm col_last">
         <div class="entry-title">
            <h3><a href="<?=$this->pocore()->call->postring->permalink(rtrim(BASE_URL, '/'), $list_post);?>"><?=$list_post['title'];?></a></h3>
         </div>
         <ul class="entry-meta clearfix">
            <li><i class="icon-calendar3"></i> <?=$this->pocore()->call->podatetime->tgl_indo($list_post['date']);?></li>
            <li><a href="<?=$this->pocore()->call->postring->permalink(rtrim(BASE_URL, '/'), $list_post);?>#comments"><i class="icon-comments"></i> <?=$this->post()->getCountComment($list_post['id_post']);?></a></li>
         </ul>
         <div class="entry-content">
            <p><?=$this->pocore()->call->postring->cuthighlight('post', $list_post['content'], '250');?>...</p>
         </div>
      </div>
   </div>
   <?php } ?>
   <div class="clear"></div>
   <div class="col_half nobottommargin">
      <?php
         $post_by_categorys2 = $this->post()->getPostByCategory('1', '1,2', 'DESC', WEB_LANG_ID);
         foreach($post_by_categorys2 as $list_post2){
         ?>
      <div class="spost clearfix">
         <div class="entry-image"><a href="<?=$this->pocore()->call->postring->permalink(rtrim(BASE_URL, '/'), $list_post2);?>"><img src="<?=BASE_URL;?>/<?=DIR_CON;?>/thumbs/<?=$list_post2['picture'];?>" alt=""></a></div>
         <div class="entry-c">
            <div class="entry-title">
               <h4><a href="<?=$this->pocore()->call->postring->permalink(rtrim(BASE_URL, '/'), $list_post2);?>"><?=$list_post2['title'];?></a></h4>
            </div>
            <ul class="entry-meta">
               <li><i class="icon-calendar3"></i> <?=$this->pocore()->call->podatetime->tgl_indo($list_post2['date']);?></li>
               <li><a href="<?=$this->pocore()->call->postring->permalink(rtrim(BASE_URL, '/'), $list_post2);?>#comment"><i class="icon-comments"></i> <?=$this->post()->getCountComment($list_post2['id_post']);?></a></li>
            </ul>
         </div>
      </div>
      <?php } ?>
   </div>
   <div class="col_half nobottommargin col_last">
      <?php
         $post_by_categorys3 = $this->post()->getPostByCategory('1', '3,2', 'DESC', WEB_LANG_ID);
         foreach($post_by_categorys3 as $list_post3){
         ?>
      <div class="spost clearfix">
         <div class="entry-image"><a href="<?=$this->pocore()->call->postring->permalink(rtrim(BASE_URL, '/'), $list_post3);?>"><img src="<?=BASE_URL;?>/<?=DIR_CON;?>/thumbs/<?=$list_post3['picture'];?>" alt=""></a></div>
         <div class="entry-c">
            <div class="entry-title">
               <h4><a href="<?=$this->pocore()->call->postring->permalink(rtrim(BASE_URL, '/'), $list_post3);?>"><?=$list_post3['title'];?></a></h4>
            </div>
            <ul class="entry-meta">
               <li><i class="icon-calendar3"></i> <?=$this->pocore()->call->podatetime->tgl_indo($list_post3['date']);?></li>
               <li><a href="<?=$this->pocore()->call->postring->permalink(rtrim(BASE_URL, '/'), $list_post3);?>#comment"><i class="icon-comments"></i> <?=$this->post()->getCountComment($list_post3['id_post']);?></a></li>
            </ul>
         </div>
      </div>
      <?php } ?>
   </div>
</div>

 

# Sekarang Mari Kita buat Auto Loop blok kategori nya silahkan edit code di atas menjadi seperti ini ..


<div class="clear"></div>
<?php
   $categorys_loop = $this->category()->getAllCategory(WEB_LANG_ID);
   foreach($categorys_loop as $category_loop){
   ?>
<div class="col_full bottommargin-lg clearfix">
   <div class="fancy-title title-border">
      <h3><a href="<?=BASE_URL;?>/category/<?=$category_loop['seotitle'];?>"><?=$category_loop['title'];?></a></h3>
   </div>
   <?php
      $post = $this->post()->getPostByCategory($category_loop['id_category'], '1', 'DESC', WEB_LANG_ID);
      foreach($post as $list_post){
      ?>
   <div class="ipost clearfix">
      <div class="col_half bottommargin-sm">
         <div class="entry-image"><a href="<?=$this->pocore()->call->postring->permalink(rtrim(BASE_URL, '/'), $list_post);?>"><img class="image_fade" src="<?=BASE_URL;?>/<?=DIR_CON;?>/uploads/medium/medium_<?=$list_post['picture'];?>" alt=""></a></div>
      </div>
      <div class="col_half bottommargin-sm col_last">
         <div class="entry-title">
            <h3><a href="<?=$this->pocore()->call->postring->permalink(rtrim(BASE_URL, '/'), $list_post);?>"><?=$list_post['title'];?></a></h3>
         </div>
         <ul class="entry-meta clearfix">
            <li><i class="icon-calendar3"></i> <?=$this->pocore()->call->podatetime->tgl_indo($list_post['date']);?></li>
            <li><a href="<?=$this->pocore()->call->postring->permalink(rtrim(BASE_URL, '/'), $list_post);?>#comments"><i class="icon-comments"></i> <?=$this->post()->getCountComment($list_post['id_post']);?></a></li>
         </ul>
         <div class="entry-content">
            <p><?=$this->pocore()->call->postring->cuthighlight('post', $list_post['content'], '250');?>...</p>
         </div>
      </div>
   </div>
   <?php } ?>
   <div class="clear"></div>
   <div class="col_half nobottommargin">
      <?php
         $post = $this->post()->getPostByCategory($category_loop['id_category'],  '1,2', 'DESC', WEB_LANG_ID);
         foreach($post as $list_post){
         ?>
      <div class="spost clearfix">
         <div class="entry-image"><a href="<?=$this->pocore()->call->postring->permalink(rtrim(BASE_URL, '/'), $list_post);?>"><img src="<?=BASE_URL;?>/<?=DIR_CON;?>/thumbs/<?=$list_post['picture'];?>" alt=""></a></div>
         <div class="entry-c">
            <div class="entry-title">
               <h4><a href="<?=$this->pocore()->call->postring->permalink(rtrim(BASE_URL, '/'), $list_post);?>"><?=$list_post['title'];?></a></h4>
            </div>
            <ul class="entry-meta">
               <li><i class="icon-calendar3"></i> <?=$this->pocore()->call->podatetime->tgl_indo($list_post['date']);?></li>
               <li><a href="<?=$this->pocore()->call->postring->permalink(rtrim(BASE_URL, '/'), $list_post);?>#comment"><i class="icon-comments"></i> <?=$this->post()->getCountComment($list_post['id_post']);?></a></li>
            </ul>
         </div>
      </div>
      <?php } ?>
   </div>
   <div class="col_half nobottommargin col_last">
      <?php
         $post = $this->post()->getPostByCategory($category_loop['id_category'],  '3,2', 'DESC', WEB_LANG_ID);
         foreach($post as $list_post){
         ?>
      <div class="spost clearfix">
         <div class="entry-image"><a href="<?=$this->pocore()->call->postring->permalink(rtrim(BASE_URL, '/'), $list_post);?>"><img src="<?=BASE_URL;?>/<?=DIR_CON;?>/thumbs/<?=$list_post['picture'];?>" alt=""></a></div>
         <div class="entry-c">
            <div class="entry-title">
               <h4><a href="<?=$this->pocore()->call->postring->permalink(rtrim(BASE_URL, '/'), $list_post);?>"><?=$list_post['title'];?></a></h4>
            </div>
            <ul class="entry-meta">
               <li><i class="icon-calendar3"></i> <?=$this->pocore()->call->podatetime->tgl_indo($list_post['date']);?></li>
               <li><a href="<?=$this->pocore()->call->postring->permalink(rtrim(BASE_URL, '/'), $list_post);?>#comment"><i class="icon-comments"></i> <?=$this->post()->getCountComment($list_post['id_post']);?></a></li>
            </ul>
         </div>
      </div>
      <?php } ?>
   </div>
</div>
<?php } ?>

 

Nah sekarang kalian tidak perlu repot - repot lagi menambahkan code ketika kalian menambahkan kategori baru . filenya Home.php dapat kalian download DISINI semoga bermanfaat . salam coder

 

.

Ayo Komentar