MVC: view and controller model in the framework

The web application developer base is currently using the framework. This product uses the YII framework. In the framework there is the MVC concept stands for Model, View and Controlller.
In principle that there is a separation of the staff of the developer of the database part of the administator, the system analyst and all those associated with the table with the database structure. All the staff in this section are addressing in the Model.
For staff in the layout, artistic look of the web associated with CSS, image files and web design, all of these will handle View. And the last is the staff section that connects the view (view) with the database, that is the programmer, software enginnering, which is related to the procedure, syntax and everything related to the control, this section handles the Controller.

All staff with their own expertise can not compare, because they have their own advantages and disadvantages. So they are expected to support and complement each other to develop a reliable web.

MVC is more complicated than IDE?

If you have ever studied programming, and try to compare IDE based programming with those that do not. IDE is an integrated development environment (please correct if wrong), which is a feature in the compiler that comes with the form design, database and script script writing. <more> The easiest example of this IDE compiler is visual basic. You can easily set the location of the text box object and the command button you want, just by click and drag. If you want to ngCoding, simply by double clicking on the object that is considered to have its event, the compiler will automatically provide a place to write the coding. When you want to see the results of work, simply by pressing F5 then the project will display according to your design earlier, like you design according to what you want.
How about web develop with MVC concept. Web applications with this concept, will separate the parts for layout design, database and place the coding script. Because of the web base, we will upload the results on hosting (read: server) then, in general, contains the .php file and some css for the design.
If still on localhost (offline), all work will be separated in certain folder. And by using notepad ++, we design. The design here is different from the IDE concept, because there is no visa design that is clearly visible. So at this stage, we must understand first with its framework.

CMultiFileUpload to upload files

A sweetener feature in a web is an animated image. Here it can mean moving and changing images. On this web, there is a silder who always change the image, can even added or deleted images if not like. This slider image management module is in the "Upload Image" menu. With the database design to accommodate the uploaded file name, we will direct the slider path to the folder to save it.

With CMultiFileUpload extentiion we can upload multiple image files at once. The Folders path is set inside the params file that resides   /config/params.php

here is the existing slider coding script

$sql="SELECT * FROM file_diupload order by id";
        $dataProvider2=new CSqlDataProvider($sql,array(
            'keyField' => 'id',
            foreach($dataProvider2->getData() as $i=>$ii)

View Flow in Yii

Working with the framework, in the current web develop, should understand the concept of MVC. In this post, will sy tangent about the view. In the jni section, handle the look or layout of web design. Yii framework, has a plot in the view as follows.
1. Initially first, by default the web will access the index.php file located  in view/site/index.php
2. The default view yii, can be modified by converting the file into public variable $ layout declared in siteController
3. Suppose a public variable $layout="//layouts/coulumn2"
4. Please modif the coulumn2.php file that is on protected/view/layouts/
note the above script coulumn2.php
<?php $this->beginContent('//layouts/main'); ?>
5. You can add a Div or an additional tag. If you want a better view, then learn the themes with css bostraps
6. So on, when opening the module, then note the public variable $ layout that exist in each controller.

In summary, the View flow can be written Main.php ->coulumn2.php->controller->_form

Editme with a different touch with more

The blog creation phase with the framework (Yii), is to add an extension to simplify article writing. In this blog is used editMe extension. One of the advantages is able to upload image files (in our PC) to be inserted in the article. When the article has been posted, it appears the drawback, the article will look entirely along with the inserted image.
It is less efficient in terms of, the speed of web display. Every internet browser opens, in fact, will also download the files and images that look, meaning it will be lavish pulse :) and also slow when displaying web pages.

One way is to add procedures on the web, so in the article can be inserted more markers. Here is his script:

public function moreLink($idnya,$isinya)
        if(strstr($isinya, '&lt;more&gt;', true)==false)
        { $hasil= $isinya; }
            $hasil=strstr($isinya, '&lt;more&gt;', true);
            $hasil= $hasil.$isilink='<a href="../post/'.$idnya.'">SELENGKAPNYA</a>';
       return $hasil;

Every article that appears on the web page will always be truncated, precisely limited by the visible text, in accordance with the writing of "more" in the article itself. The series of articles will end with the words COMPLETE and when we click on the writing INSTANTLY it will lead to the article in full and eliminate the word COMPLETE earlier. Here's the coding:

public function tanpaMore($isinya)
       $hasil=str_replace("&lt;more&gt;","" , $isinya);
       return $hasil;


CgridView updates automatically when create, update and delete views # 1

By default, in the Yii framework, the CgridView widget is inside admin.php. This component is useful for displaying data and as an effective search for subsequent data manipulation. So it can be said, CgridView is always in Yii project.
When creating and updating, CgridView can be displayed in 1 form with the same input, it needs a coding modification. Look at the picture below: <more>
Stage 1, to do CgridView order to display the data directly in accordance with the create as follows:
Open the admin.php file in protected / view / nama_view_anda .... Copy and paste it in _form.php under the cover of its div form

</div><!-- penutup  form -->
<?php $this->widget('zii.widgets.grid.CGridView', array(
                                        'class' => 'CButtonColumn',
            'template' => '{update}{delete}',
)); ?>
Modify the coding on the controller
In actionCreate, replace the string coding as follows:
//$this->redirect(array('view','id'=>$model->id));   INI YANG ASLI
Please be practiced to save this new data, it will be able to get new data appear on the grid.
For the next article is a modification in actionUpdate. Please wait.

CgridView updates automatically when create, update and delete views no 2

As my promise in the title article CgridView update otomatis saat create, update dan delete pada 1 tampilan  # 1 , I will continue to make a trick on the gridview. In the first article, when uploading files, there are 2 events that take place: upload files in a specific folder and save the file name in a particular table.
Now we will discuss how to delete the uploaded data in the table and at the same time to delete the stored files. And it will directly remove the data in its gridview so it always updates

1.Open file in view as upload form
Modified cgridview
             'class' => 'CButtonColumn',  
             'template' => '{delete}',
Be as below:
array( 'class' => 'CButtonColumn',
                'template' => '{open}',
                'buttons' => array(
  'open' => array(
                 'url' => 'Yii::app()->createUrl("fileDiupload/conAktif", array("id"=>$data->id))',
                 'imageUrl' => Yii::app()->request->baseUrl . '/images/delete.png',  )
2. Make the conActive function in its controller
public function actionConAktif($id)
3. Make conactive views
<?php echo $this->renderPartial('_conformAktif', array(
                )); ?>
4.Make view _conformActive '
                                          hasil=window.confirm("Yakin hapus file/data ini ?");
                                                        window.location.href="../hapus/" + <?php echo $model->id ?>;
            }                             ?>       
5. After that go back to the controller to create the delete function
public function actionHapus($id)
                        //hapus item data yg terpilih'
                        $file = $model->nama_file;
                        $folder =Yii::app()->params['uploadDir'];
                         if( $file != null  &&  file_exists( $folder.'/'.$file ) )
             unlink(getcwd().'/'.$folder.$file); //hapus file yg terpilih datanya
                                         if ($model->delete())
        $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('unggah/unggahfile'));

Please follow the steps above, if any bugs learn its errors,

Menampilkan ikon bootstrap di web dengan bootstrap versi 4

Dalam pembuatan aplikasi web, ada beberapa bahasa pemrograman yang mesti dikuasai atau setidaknya paham. Apabila aplikasi web berbasis php, maka untuk lebih cepat dalam membuat dan men "deploy" aplikasi ke web server, disarankan untuk mempelajari juga kerangka kerja atau framework. Dalam framework, sudah disediakan fungsi dan aturan sistem untuk masalah keamanan data, routing  ( pindah page, aturan POST - GET dll ), caching dan lainnya. Setelah framework dikuasai, pengembang aplikasi lebih fokus ke sistem bisnis itu sendiri, sehingga kerjaan pengembang lebih terbantukan.

Oleh karena web besifat publik, maka masalah tampilan harus diperhatikan juga. Terlebih dewasa ini, dengan adanya perangkat "mobile" maka desain web harus dapat menyesuaikan ukuran dari perangkat. Masalah tampilan di web, diatur dalam file html dan css. Tampilan adalah ranah client side atau sisi pengguna, untuk itu mesti juga mempelahari kerangka kerja pengaturan layour web ini.

Twiiter memperbolehkan penggunaan secara gratis kerangka layout web nya, yang dikenal dengan BOOTSTRAP. Dan ini telah menggunakan boostrap versi 4, yang merupakan versi paling update untuk saat ini , Mei 2018. Akan tetapi saat memakai vesi 4 ini, ada banyak penyesuain yang mesti diperhatikan, antara lain penggunaan glyphicons. 

Glyphicons adalah tampilan ikon-ikon kecil yang sudah ada di bootstrap, sehingga membantu pengembang web dalam mempercantik tampilan. Sekali lagi pengembang tidak susah susah meminta bantuan desain grafis jika hanya membuat ikon. Fitur glyphicons tidak bisa digunakan secara langsung di versi 4 ini, ada beberapa langkah untuk itu, yaitu:

  1. Unduh lah file glyphicons.css ini  ( silakan klik

      2.extract dan taruh lah di folder css di project web

      3.coding lah di bagian header untuk deklarasi penggunaan file css itu

<? Php Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . "/css/glyphicons.css"); ?>


Dan ikon bootstrap siap digunakan.

<class="glyphicon glyphicon-record">

Suatu ikon gambar disket, yang mempunyai maksud untuk menyimpan