63 article php artikelsing one foreach dataProvider

63 article php artikelsing one foreach dataprovider

This preview shows page 63 - 69 out of 82 pages.

63 <article> <?php $artikelsing = \common\models\Posting::find()->one(); foreach ($dataProvider->models as $key => $artikels) { ?> <div class="post-image"> <div class="post-heading"> <h2><?=$artikels['judul']?></h 2> </div> <img src="<?php echo('../../backend/web/uploads/post ing/'.$artikels['foto'])?>" alt="responsive" class="img- responsive"> </div> <p><p><?php echo '<p>'.substr($artikels >isi,0,10).'...</p>'; ?></p></p> <div class="bottom-article"> <ul class="meta-post"> <?php echo '<li><small>Posted at '. date($artikels- >tglPosting).'</small>< /li>'?> <li><i class="icon- user"></i><a href="#"> Admin</a></li> <li><i class="icon- comments"></i><a href="#">4 Comments</a></li> </ul> <!--<a href="#" class="pull-right">Continue reading <i class="icon-angle- right"></i></a>--> <?php echo '<p><a class="link" href="'.\Yii::$app- >urlManager- >createUrl(['site/fullpost', 'id' => $artikels- >idPosting]).'">Read More</a></p>';?> </div>
Image of page 63

Subscribe to view the full document.

64 <?php }?> </article> Sedangkan pada controller , tambahkan source code berikut: public function actionIndex() { $searchModel = new \backend\models\PostingSearch(); $dataProvider = $searchModel- >search(Yii::$app->request- >queryParams); return $this->render('index', [ 'searchModel' => $searchModel, ] ); } 6) Memilih informasi berdasarkan kategori Gambar 13. Tampilan Kategori pada menu home Website informasi bisnis ini juga memberikan fitur mencari informasi berdasarkan kategori yang dibutuhkan. Bisnis dibidang makanan, pakaian, teknologi, atau bidang lain. Bidang-bidang tersebut dikelompokkan dalam satu kategori agar lebih mudah dicari. Berikut ini source code untuk menampilkan informasi berdasarkan kategori tertentu
Image of page 64
65 <?php $items=[]; foreach($cate as $ca){ items[]=['label' => $ca->namaKategori , 'url' => \Yii::$app->urlManager- >createUrl(['site/postcategory', 'id' => $ca->idKategori])]; } echo Nav::widget(['items' => $items, ]); ?> Saat kita memilih kategori yang ingin diambil, maka akan muncul tampilan informasi yang terkait dengan kategori yang telah dipilih. Berikut ini tampilan informasi bisnis yang sudah dipilih berdasarkan kategori tertentu Gambar 14. Tampilan menu berdasarkan kategori tertentu Pada controller, tambahkan source code berikut public function actionPostcategory($id) { $lp = \common\models\Posting::find() ->orderBy('idPosting DESC') ->limit(3) ->all();
Image of page 65

Subscribe to view the full document.

66 $cate = \common\models\Kategori::find() ->orderBy('idKategori ASC') ->all(); $countQuery = clone $p1; $pages = new \yii\data\Pagination(['totalCount'=>$c ountQuery->count()]); $p = $p1->offset($pages->offset) ->limit($pages->pageSize= 5) ->all(); return $this->render('postcategory', [ 'p'=>$p, 'cate'=>$cate, 'lp'=>$lp, 'pages'=>$pages, ] ); } Informasi yang ditampilkan dibatasi untuk satu halaman hanya menampilkan 5 informasi yang tekait. Pembatasan informasi ini menggunakan yii pagination 7) Menampilkan informasi terbaru
Image of page 66
67 Gambar 15. Tampilan menu recent posts Pada tampilan menu home, terdapat menu recent posts yang berguna untuk melihat posting terbaru. Berikut source code tampilan recent posts <?php foreach ($lp as $last) { ?> <div class="blog-grids"> <div class="blog-grid-left"> <img src="<?php echo ('../../backend/web/uploads/posting/ '.$last['foto']) ?> " alt="" class="img-responsive"/> </div> <div class="blog-grid-right"> <?php echo '<h4><a href="'.\Yii::$app->urlManager-
Image of page 67

Subscribe to view the full document.

68 >createUrl(['site/fullpost', 'id' => $last- >idPosting]).'">'.$last['judul'].'</ a></h4>';?> <p><?php echo '<p>'.substr($last- >isi,0,10).'...</p>'; ?></p> </div> <div class="clearfix"></div> </div> <?php }?> Untuk source code pada controller sebagai berikut public function actionIndex() { $lp = \common\models\Posting::find()
Image of page 68
Image of page 69
  • Fall '17
  • DINA

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes