1
การ install CakePHP ขั้นแรกให้ไปแก้ไฟล์ core.php ก่อนและไปเปลี่ยนตัวดีบักให้เป็นโหมด 1 เมื่อเปลี่ยนเสร็จสิ้นแล้วก็ทาการบันทึกและก็ทาการสร้างไฟล์ default.ctp เสร็จแล้วทาการบันทึกพร้อมกับ upload file ไว้ในโฟรเดอร์ app/views/layouts แล้วเอาไฟล์ที่ทาการสร้างเมื่อกี้นี้มาอัพโหลดขึ้นไป จากนั้นทาการสร้างไฟล์ style.css แล้วบันทึกพร้อมกับ upload file ไว้ในโฟรเดอร์ app/webroot/css แล้วเอาไฟล์ที่ทาการสร้างเมื่อกี้นี้มาอัพโหลดขึ้นไป ในโฟรเดอร์ posts จะมีไฟล์ add.ctp edit.ctp index.ctp view.ctp ให้ทาการดาว์โหลดไฟล์เหล่านั้นมาทาการแก้ไข - ไฟล์ add.ctp
create('Post');?>
end('Submit');?> - link(__('List Posts', true), array('action'=>'index'));?>
- link(__('List Users', true), array('controller'=> 'users', 'action'=>'index')); ?>
2
- link(__('New User', true), array('controller'=> 'users', 'action'=>'add')); ?>
- link(__('List Comments', true), array('controller'=> 'comments', 'action'=>'index')); ?>
- link(__('New Comment', true), array('controller'=> 'comments', 'action'=>'add')); ?>
- link(__('List Tags', true), array('controller'=> 'tags', 'action'=>'index')); ?>
- link(__('New Tag', true), array('controller'=> 'tags', 'action'=>'add')); ?>
-ไฟล์ edit.ctp
create('Post');?>
end('Submit');?>
3
- link(__('Delete', true), array('action'=>'delete', $form>value('Post.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form>value('Post.id'))); ?>
- link(__('List Posts', true), array('action'=>'index'));?>
- link(__('List Users', true), array('controller'=> 'users', 'action'=>'index')); ?>
- link(__('New User', true), array('controller'=> 'users', 'action'=>'add')); ?>
- link(__('List Comments', true), array('controller'=> 'comments', 'action'=>'index')); ?>
- link(__('New Comment', true), array('controller'=> 'comments', 'action'=>'add')); ?>
- link(__('List Tags', true), array('controller'=> 'tags', 'action'=>'index')); ?>
- link(__('New Tag', true), array('controller'=> 'tags', 'action'=>'add')); ?>
-ไฟล์ index.ctp
counter(array( 'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true) ));
4
?>
| sort('id');?> | sort('name');?> | sort('date');?> | sort('content');?> | sort('user_id');?> | |
> | | | | |
5
link($post['User']['name'], array('controller'=> 'users', 'action'=>'view', $post['User']['id'])); ?> | link(__('View', true), array('action'=>'view', $post['Post']['id'])); ?> link(__('Edit', true), array('action'=>'edit', $post['Post']['id'])); ?> link(__('Delete', true), array('action'=>'delete', $post['Post']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $post['Post']['id'])); ?> |
prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?> | numbers();?> next(__('next', true).' >>', array(), null, array('class'=>'disabled'));?>
- link(__('New Post', true), array('action'=>'add')); ?>
- link(__('List Users', true), array('controller'=> 'users', 'action'=>'index')); ?>
6
- link(__('New User', true), array('controller'=> 'users', 'action'=>'add')); ?>
- link(__('List Comments', true), array('controller'=> 'comments', 'action'=>'index')); ?>
- link(__('New Comment', true), array('controller'=> 'comments', 'action'=>'add')); ?>
- link(__('List Tags', true), array('controller'=> 'tags', 'action'=>'index')); ?>
- link(__('New Tag', true), array('controller'=> 'tags', 'action'=>'add')); ?>
-ไฟล์ view.ctp
- >
- >
- >
- >
- >
- >
7
- >
- >
- >
- > link($post['User']['name'], array('controller'=> 'users', 'action'=>'view', $post['User']['id'])); ?>
- link(__('Edit Post', true), array('action'=>'edit', $post['Post']['id'])); ?>
- link(__('Delete Post', true), array('action'=>'delete', $post['Post']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $post['Post']['id'])); ?>
- link(__('List Posts', true), array('action'=>'index')); ?>
- link(__('New Post', true), array('action'=>'add')); ?>
- link(__('List Users', true), array('controller'=> 'users', 'action'=>'index')); ?>
- link(__('New User', true), array('controller'=> 'users', 'action'=>'add')); ?>
- link(__('List Comments', true), array('controller'=> 'comments', 'action'=>'index')); ?>
- link(__('New Comment', true), array('controller'=> 'comments', 'action'=>'add')); ?>
8
- link(__('List Tags', true), array('controller'=> 'tags', 'action'=>'index')); ?>
- link(__('New Tag', true), array('controller'=> 'tags', 'action'=>'add')); ?>
จากนั้นทาการบันทึกพร้อมกับ upload file ทั้ง 4 ไฟล์ และมาดูที่หน้า Internet Explorer แล้วเข้าไปที่ 10.4.6.155/~49412545/blog/posts/ จากนั้นจะเห็นว่าตัวอักษรบ้างตัวเป็นภาษาที่เราไม่สามารถอ่านออกแต่สามมารถแก้ไขได้โดยที่เราก ดที่ Format -> Encode in UTF-8 แล้วทาการ upload file ขึ้นไปใหม่ แล้วหลังจากนั้นก็ทาการตรวจสอบของทุกๆหน้าว่ามีความผิดพลาดตรงไหนหรือเปล่าถ้ามีส่วนที่ผิ ดพลาดก็ทาการแก้ไขของส่วนไฟล์นั้นๆ