Tik’s Blog

ร้อยแปดพันเก้า

Archive for พฤษภาคม 2008

ใส่ text หลัง input ใน CakePHP

without comments

คุณสามารถใส่เนื้อหาต่อท้าย input() ใน CakePHP ได้โดยที่เนื้อหานั้นยังอยู่ใน div ของ label/input ที่ Cake สร้างมาให้โดยใส่ 'after' เข้าไปใน options ของ input() ครับ ยกตัวอย่างเช่น:

echo $form->input('Model.field', array('label' => 'Value:', 'after' => 'ตัวหนังสือที่ถูกแสดงหลัง input')); 

ค่าของ 'after' จะถูกต่อท้าย input

ในกรณีคล้ายๆกันคุณสามารถใช้ 'before'  ถ้าอยากแสดงเนื้อหาก่อน input box ได้ด้วย (แต่จะแสดงหลัง label นะครับ)

Written by sukita

พฤษภาคม 23, 2008 at 4:17 am

บันทึกโพสใน Programming

Tagged with

อีกหนึ่งวิธีในการแสดง password field ใน CakePHP 1.2

without comments

นอกจากการใช้ $html->password(‘User.password’) เพื่อแสดง field สำหรับ input password ยังมีอีกวิธีที่ทำได้นั่นก็คือการใช้ $html->input(‘User.password’, array(‘type’ => ‘password’, ‘label’ => ‘รหัสผ่าน:’))

วิธีที่สองต่างกับแบบแรกโดยที่มันสร้าง <div> เพื่อครอบ <label> กับ <input> ที่ generate โดย view ของ CakePHP และก็ทำงานกับ validation ได้ด้วย

แต่วิธีแรกจะสร้างเฉพาะ <input> สำหรับ password เท่านั้น โดยไม่สร้าง label ให้

Written by sukita

พฤษภาคม 15, 2008 at 5:54 pm

บันทึกโพสใน Programming

Tagged with

Framework Learning Curve

without comments

เมื่อกี๊เพิ่งเจอปัญหากับ Rails นิดหน่อยเกี่ยวกับ CSRF InvalidAuthenticityToken exception

ในหนังสือใช้ตัวอย่างนี้ แต่เวลาเขียนทดลองจริงมีอีกปัญหานึง .. สำหรับ framework ที่วิ่งเร็วปรู๊ดอย่างรวดเร็ว เอกสารที่ update ตามไม่ทันก็ทำให้การเรียนรู้ยากขึ้นไปอีกสำหรับ beginner ได้เหมือนกัน

Written by sukita

พฤษภาคม 11, 2008 at 4:27 pm

บันทึกโพสใน Uncategorized

ช่วยกันแปล พัฒนาไทยให้ก้าวไกลขึ้น

with one comment

อ่านเจอบล๊อกของคุณ wiennat แล้วรู้สึกว่าโดนใจ

จากประสบการณ์ส่วนตัวที่ผ่านมาทำให้เห็นได้มากว่าปัญหาเรื่องภาษาเป็นกำแพงมหึมาที่ทำให้การพัฒนาในด้าน IT ของไทยไปได้ช้ามากๆ และไม่ค่อยมีคุณภาพ … เนื่องจากภาษาอังกฤษไม่ใช่ภาษาแม่ของเรา และ software ต่างๆถูกพัฒนาโดยใช้ภาษาอังกฤษเป็นหลัก ไม่ว่าจะเป็นภาษาที่ใช้เขียน โปรแกรมที่ใช้เขียน เอกสารประกอบ ฯลฯ ทำให้เวลาเราต้องการค้นหาข้อมูลเชิงลึกสามารถทำได้ยาก เพราะเวลาจะหาก็อาจจะไม่รู้หาโดยใช้คำว่าอะไร และหามาก็มีแต่ภาษาอังกฤษ ทำให้อ่านไม่รู้เรื่องอีก

ปัญหาที่ผมคิดว่าใหญ่กว่าคือผู้นำทางความคิดด้านไอที่ส่วนใหญ่ก็ใช้ภาษาอังกฤษเพื่อสื่อความรู้ใหม่ๆเป็นหลัก ยิ่งไม่สามารถติดตาม trend ที่มีประโยชน์ หรือซึมซับแนวคิดของบุคคลเก่งๆ ยิ่งแย่

พออ่านไม่รู้เรื่องก็อาจทำให้ท้อ ท้อก็ทำให้หยุดเรียนรู้สิ่งใหม่ๆ หยุดขวนขวาย รับส่ิงที่มีตามมีตามเกิด … การแก้ปัญหาผ่านการแปลก็เป็นการแก้ปัญหาทางหนึ่งที่ยั่งยืน ถึงแม้ว่าจะใช้เวลาและกำลังคนมาก  แต่ก็น่าลองทำ

ผมขอเป็นเสียงสนับสนุนการแปลเอกสาร software ต่างๆเป็นภาษาไทยด้วยคนละกัน และใครๆที่อยากมีส่วนร่วม จะมากจะน้อยผมว่าก็ทำประโยชน์ให้ส่วนรวมได้ทั้งนั้น … Let’s do it

Written by sukita

พฤษภาคม 5, 2008 at 2:58 pm

บันทึกโพสใน Uncategorized

เซ็ทค่า Leopard Terminal สำหรับภาษาไทย

without comments

export LC_ALL=en_US.UTF-8

export LANG=en_US.UTF-8

แก้สองค่านี้แล้ว Mercurial command line work ภาษาไทยยังไม่เจ๊ง และ commit log ภาษาไทยของ svn work

Written by sukita

พฤษภาคม 5, 2008 at 10:17 am

บันทึกโพสใน Uncategorized

Tagged with , ,

Setting up Virtual Hosting on Leopard

without comments

This is how I set up virtual hosting to point to a “virtual” domain on my localhost for development and testing.

The problem actually comes from having to set RewriteBase as mentioned in the previous post. This is very inconvenient, as the .htaccess being deployed in production will be different from the .htaccess on my machine. The one on my machine requires a RewriteBase to /~Me/cake, whereas the one on the production server does not require this.

Since all files are under version control, setting RewriteBase and undoing the changes when deploying is not much fun at all.

After digging around, I found one (probably overengineered) solution. Hell, it works now, so this is a reminder in case I need to do all this again.

  1. First thing is to enable virtual hosting in /private/etc/apache2/httpd.conf by uncommenting the line “Include /private/etc/apache2/extra/httpd-vhosts.conf”.
  2. Then edit httpd-vhosts.conf. The setting looks something like:

NameVirtualHost *:80

<VirtualHost *:80>

    DocumentRoot “/Library/WebServer/Documents”

</VirtualHost>

<VirtualHost *:80>

    DocumentRoot “/Users/Me/Sites/cake/”

    ServerName production

</VirtualHost>

The first VirtualHost block is the default host. I added this so that the old behavior works (as recommended in Apache’s documentation).

The second VirtualHost is the new “virtual” domain for local use. The domain name is “production”, so I can access the special web site using “http://production/”.

Since “production” is a domain name I made up, I must define a special lookup in /private/etc/hosts by adding a line to the file: “127.0.0.1 production”. What this means is when the OS looks up the domain “production”, it will resolve to IP 127.0.0.1.

Restart Apache by “sudo apachectl restart” and that should do it. Pointing to “http://production” should now show your CakePHP app site. RewriteBase is no longer needed. Deploying should be a bit easier.

Written by sukita

พฤษภาคม 1, 2008 at 5:12 pm

บันทึกโพสใน Uncategorized