Fix Virtual Network Interface Card to eth0
===========================================
When we move the image to various hosts,
1) the interface name will keep running to eth1, eth2, eth3 and so on
2) the ip address will not automatically obtained.
because inside /etc/network/interfaces
....
iface eth0 inet dhcp
...
For solution Go To network-interface-in-linux.html
HTTP request status Fails
==========================
http://drupal.org/node/588186
Showing posts with label drupal. Show all posts
Showing posts with label drupal. Show all posts
Friday, November 18, 2011
Saturday, October 29, 2011
get absolute path in drupal modules
The following codes is in /var/www/drupal-6.22/sites/all/modules/mymodule/mymodule.module
echo dirname(__FILE__)
= /var/www/drupal-6.22/sites/all/modules/mymodule
echo realpath(".");
= /var/www/drupal-6.22
echo realpath(drupal_get_path('module', 'mymodule'));
= /var/www/drupal-6.22/sites/all/modules/mymodule
echo $_SERVER['DOCUMENT_ROOT'] . base_path();
= /var/www//drupal-6.22/
global $base_url;
echo $base_url;
= http://bmms:8080/drupal-6.22
echo base_path(); // drupal function
= /drupal-6.22/
$path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'filename.ext';
$data = file( $path );
foreach($data as $value) {
$output .= "$value";
}
http://php.net/manual/en/language.constants.predefined.php
http://php.net/manual/en/function.dirname.php
http://php.net/manual/en/function.realpath.php
echo dirname(__FILE__)
= /var/www/drupal-6.22/sites/all/modules/mymodule
echo realpath(".");
= /var/www/drupal-6.22
echo realpath(drupal_get_path('module', 'mymodule'));
= /var/www/drupal-6.22/sites/all/modules/mymodule
echo $_SERVER['DOCUMENT_ROOT'] . base_path();
= /var/www//drupal-6.22/
global $base_url;
echo $base_url;
= http://bmms:8080/drupal-6.22
echo base_path(); // drupal function
= /drupal-6.22/
$path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'filename.ext';
$data = file( $path );
foreach($data as $value) {
$output .= "$value";
}
http://php.net/manual/en/language.constants.predefined.php
http://php.net/manual/en/function.dirname.php
http://php.net/manual/en/function.realpath.php
Labels:
drupal
Friday, October 28, 2011
attach files to drupal contemplate pages
[tag] embed height="310" width="720" type="image/svg+xml" src=< ? php print file_create_url( images/image1.svg ); ? > [tag]
Labels:
drupal
Tuesday, August 30, 2011
Taxonomy vocabulary term in drupal
Taxonomy
vocabulary
===========
คือ หัวข้อ เช่น สินค้าเสื้อ มี vocabulary คือ size และ อีก vocabulary เพื่อบอกว่าเป็นเสื้อสําหรับผู้ชายหรือผู้หญิง
term
====
term (หรือ tag) คือ ค่าที่เป็นไปได้ของแต่ละ vocabulary เช่น
S, M หรือ L สำหรับ size เสื้อ
กำหนดเป็น hierache ได้เช่น จังหวัด เขต แขวง
สามารถเอาไปผูกกับ node ข้อมูล ได้หลายวิธี
- กำหนดผ่าน Content management » Taxonomy » Edit vocabulary » Content types
- http://drupal.org/project/hierarchical_select
- Administer » Content management » {Content name} เพิ่ม field ประเภท Content Taxonomy Fields
drush dl content_taxonomy
drush en -y content_taxonomy content_taxonomy_options
ใน drupal ถ้าใช้ ubercart จะมีอีกคู่นึงที่คล้ายกัน คือ attribute + option
http://www.ubercart.org/docs/user/10961/product_attributes_and_options
vocabulary
===========
คือ หัวข้อ เช่น สินค้าเสื้อ มี vocabulary คือ size และ อีก vocabulary เพื่อบอกว่าเป็นเสื้อสําหรับผู้ชายหรือผู้หญิง
term
====
term (หรือ tag) คือ ค่าที่เป็นไปได้ของแต่ละ vocabulary เช่น
S, M หรือ L สำหรับ size เสื้อ
กำหนดเป็น hierache ได้เช่น จังหวัด เขต แขวง
สามารถเอาไปผูกกับ node ข้อมูล ได้หลายวิธี
- กำหนดผ่าน Content management » Taxonomy » Edit vocabulary » Content types
- http://drupal.org/project/hierarchical_select
- Administer » Content management » {Content name} เพิ่ม field ประเภท Content Taxonomy Fields
drush dl content_taxonomy
drush en -y content_taxonomy content_taxonomy_options
ใน drupal ถ้าใช้ ubercart จะมีอีกคู่นึงที่คล้ายกัน คือ attribute + option
http://www.ubercart.org/docs/user/10961/product_attributes_and_options
Labels:
drupal
Thursday, June 30, 2011
Using Drupal to build a web app #2
Import Initial data ?
=====================
ในมุมการสร้าง web app (ที่ไม่ใช่ cms)
อาจมีข้อมูลระบบเก่าที่ต้อง import เข้า
แบ่งออกได้เป็นหลายกรณี เช่น
เป็นข้อมูล master ไม่มี foreign key
ในรูปแบบ เช่น csv, xml, หรือ table อยู่ใน ฐานข้อมูล
import ได้หลายวิธีเช่น
http://www.lullabot.com/articles/drupal-data-imports-migrate-and-table-wizard
http://drupal.org/node/1035296
เป็นข้อมูลที่มีความสัมพันธ์ one to many
เช่น table อัลบั๊มเพลง สัมพันธ์กับ table เพลง
(ซึ่งจะมีเพียงอัลบั๊มเดียว link ไปยัง เพลง
= เพลงหนึ่งเพลงอยู่ในอัลบั๊มเดียวเท่านั้น)
import ด้วย http://drupal.org/project/feeds
ผู้ฟังแต่ละคน ชอบเพลงได้หลายเพลง
เพลงแต่ละเพลงมีผู้ชอบฟังได้หลายคน
(ยังไม่ได้ศึกษา)
ติดต่อสื่อสารกับระบบอื่นๆได้
====================
XMLRPC, JSON, REST, AJAX, Webservice ...
ด้วย module ต่างๆ เช่น http://drupal.org/project/services
ตัวอย่าง
Building a webservice
http://jeroenbourgois.be/get-drupal-data-to-an-external-site
http://www.sparklepod.com/myblog/drupal-services-and-json-server-part-2/
เหมาะแก่การประมวลผล เพื่อออก report ?
==================================
- run sql select insert, update, delete ได้
- มี api มาให้แทน sql statement
- Drupal มีการเก็บข้อมูลใน table เฉพาะ
ซื่งออกแบบให้รองรับการเก็บบันทึกการแก้ไขข้อมูล หลายครั้ง revision
ไม่ใช่เก็บเฉพาะครั้งล่าสุด
ดังนั้น อย่าคาดหวังว่า ข้อมูลจะอยู่บน table เดียว ให้ select ง่ายๆ (ถ้าไม่ได้ผ่าน drupal api)
- Drupal ไม่ใช่ Object-Oriented (เป็น Procedural)
ถ้าคาดหวัง จะมี ORM ต้องลง http://drupal.org/project/orm เพิ่ม
- Drupal ไม่รองรับ Atomic Transaction !!!
Others
=======
- Drupal ยืดหยุ่นสูง
- มี User Interface ให้แก้ไขเมนู, เพิ่มหน้า + ใส่รูป (เช่น FCKeditor)
(ไม่ต้อง code ใดๆ)
รองรับ markdown (http://tewson.com/markdown)
- search + แสดงข้อมูล บน table ที่มีอยู่แล้ว (น่าจะเรียกว่า custom table)
http://drupal.org/project/data (ไม่ต้อง code อีกเช่นเดิม)
(join ความสัมพันธ์กับ content บน drupal ได้)
- ฟรีจริงๆ (ไม่เหมือน บน joomla ที่หลาย module ฟรีตัว demo)
- มี http://drupal.org/project/panels ที่ทำให้แต่ละหน้ามี layout ที่ต่างกันได้
- สร้าง form ขึ้นมาเฉพาะงาน
เช่น http://drupal.org/project/webform (making surveys)
ทำหน้า frontpage http://drupal.org/project/front
หน้า contact us http://drupal.org/project/contact_forms
บอกว่า drupal มี Acquia เป็นเบื้องหลัง เหมือน fedora กับ Redhat
(http://www.isriya.com/node/2355/why-geeks-love-drupal)
มี drush เป็นทางเลือกในการติดตั้ง & maintainance >> http://ubuntuclub.com/node/3159/drupal-ขั้นเทพ-ด้วย-drush
ตัวอย่างเทพๆ ในการ setup ลงบน centos
http://thedrupalblog.com/creating-centos-server-installation-apache-mysql-tomcat-php-drupal-and-solr
ทิ้งท้ายด้วย อีกตัวอย่าง(ที่น่าตื่นตา) การใช้ drupal สร้าง web สมัครงาน (ภายในเวลา 30 นาที)
http://benbuckman.net/tech/11/02/drupal-application-framework-bostonphp-competition
ชั่งน้ำหนักกันเอาแล้วกันนะครับ ว่าเหมาะสมกับ Project ที่กำลังทำหรือเปล่า
สำหรับบางงาน อาจจะเหมาะมากๆ
=====================
ในมุมการสร้าง web app (ที่ไม่ใช่ cms)
อาจมีข้อมูลระบบเก่าที่ต้อง import เข้า
แบ่งออกได้เป็นหลายกรณี เช่น
เป็นข้อมูล master ไม่มี foreign key
ในรูปแบบ เช่น csv, xml, หรือ table อยู่ใน ฐานข้อมูล
import ได้หลายวิธีเช่น
http://www.lullabot.com/articles/drupal-data-imports-migrate-and-table-wizard
http://drupal.org/node/1035296
เป็นข้อมูลที่มีความสัมพันธ์ one to many
เช่น table อัลบั๊มเพลง สัมพันธ์กับ table เพลง
(ซึ่งจะมีเพียงอัลบั๊มเดียว link ไปยัง เพลง
= เพลงหนึ่งเพลงอยู่ในอัลบั๊มเดียวเท่านั้น)
import ด้วย http://drupal.org/project/feeds
ผู้ฟังแต่ละคน ชอบเพลงได้หลายเพลง
เพลงแต่ละเพลงมีผู้ชอบฟังได้หลายคน
(ยังไม่ได้ศึกษา)
ติดต่อสื่อสารกับระบบอื่นๆได้
====================
XMLRPC, JSON, REST, AJAX, Webservice ...
ด้วย module ต่างๆ เช่น http://drupal.org/project/services
ตัวอย่าง
Building a webservice
http://jeroenbourgois.be/get-drupal-data-to-an-external-site
http://www.sparklepod.com/myblog/drupal-services-and-json-server-part-2/
เหมาะแก่การประมวลผล เพื่อออก report ?
==================================
- run sql select insert, update, delete ได้
- มี api มาให้แทน sql statement
- Drupal มีการเก็บข้อมูลใน table เฉพาะ
ซื่งออกแบบให้รองรับการเก็บบันทึกการแก้ไขข้อมูล หลายครั้ง revision
ไม่ใช่เก็บเฉพาะครั้งล่าสุด
ดังนั้น อย่าคาดหวังว่า ข้อมูลจะอยู่บน table เดียว ให้ select ง่ายๆ (ถ้าไม่ได้ผ่าน drupal api)
- Drupal ไม่ใช่ Object-Oriented (เป็น Procedural)
ถ้าคาดหวัง จะมี ORM ต้องลง http://drupal.org/project/orm เพิ่ม
- Drupal ไม่รองรับ Atomic Transaction !!!
Others
=======
- Drupal ยืดหยุ่นสูง
- มี User Interface ให้แก้ไขเมนู, เพิ่มหน้า + ใส่รูป (เช่น FCKeditor)
(ไม่ต้อง code ใดๆ)
รองรับ markdown (http://tewson.com/markdown)
- search + แสดงข้อมูล บน table ที่มีอยู่แล้ว (น่าจะเรียกว่า custom table)
http://drupal.org/project/data (ไม่ต้อง code อีกเช่นเดิม)
(join ความสัมพันธ์กับ content บน drupal ได้)
- ฟรีจริงๆ (ไม่เหมือน บน joomla ที่หลาย module ฟรีตัว demo)
- มี http://drupal.org/project/panels ที่ทำให้แต่ละหน้ามี layout ที่ต่างกันได้
- สร้าง form ขึ้นมาเฉพาะงาน
เช่น http://drupal.org/project/webform (making surveys)
ทำหน้า frontpage http://drupal.org/project/front
หน้า contact us http://drupal.org/project/contact_forms
บอกว่า drupal มี Acquia เป็นเบื้องหลัง เหมือน fedora กับ Redhat
(http://www.isriya.com/node/2355/why-geeks-love-drupal)
มี drush เป็นทางเลือกในการติดตั้ง & maintainance >> http://ubuntuclub.com/node/3159/drupal-ขั้นเทพ-ด้วย-drush
ตัวอย่างเทพๆ ในการ setup ลงบน centos
http://thedrupalblog.com/creating-centos-server-installation-apache-mysql-tomcat-php-drupal-and-solr
ทิ้งท้ายด้วย อีกตัวอย่าง(ที่น่าตื่นตา) การใช้ drupal สร้าง web สมัครงาน (ภายในเวลา 30 นาที)
http://benbuckman.net/tech/11/02/drupal-application-framework-bostonphp-competition
ชั่งน้ำหนักกันเอาแล้วกันนะครับ ว่าเหมาะสมกับ Project ที่กำลังทำหรือเปล่า
สำหรับบางงาน อาจจะเหมาะมากๆ
Labels:
drupal
Using Drupal to build a web app
จะทำ Project ใหม่ กำลังเลือก framework ก็กำหนดความคาดหวังกันซะหน่อย
เราคาดหวังอะไรจาก framework บ้าง?
================================
- เป็น web app
- ฟรี ไม่ติดเรื่องลิขสิทธิ์
- ภาษา เป็น php น่าจะดี
(เพื่อเลี่ยงปัญหาลิขสิทธิ์ java หรือความไม่แน่นอนใดๆ ที่อาจจะเกิดขึ้น)
- รองรับ postgres, mysql
- มีเอกสารเพียงพอ
- ควรอำนวยความสะดวก ในสร้าง app
(ทำงานหลักๆของ app คงไม่พ้น หน้า Search และแสดงข้อมูล
แล้วก็ Insert, Update, Delete)
framework ควรเอื้อให้พัฒนาได้อย่างเร็วๆ (เช่น Validate input data)
เคยใช้ oracle application express (APEX) สร้าง App
ให้อารมณ์เหมือน ทำ M$ Access
(คือ click ๆๆๆ แล้ว key code นิดหน่อย แล้วได้ เป็น app ขึ้นมาใช้งาน)
แต่ต่างจาก access ตรงที่หน้าจอ User Interface เป็น Web
ถ้า framework เอื้อให้ทำได้อย่าง APEX นี่จะดีมาก
- เพิ่มส่วนขยายได้
เช่น อยากเพิ่ม lib ของ AJAX, JSON, JQuery, etc.
framework ก็เอื้อให้สามารถทำได้
(ถ้าไม่ได้พร้อมใช้ ก็ขอให้มีตัวอย่างคนที่ทำสำเร็จมาแล้ว
ไม่ต้องไล่แก้ code เพื่อเพิ่มเติม module ต่างๆ)
- เขียน code เพิ่มเติมสำหรับงานใน app ของเราได้
- Import Initial data ได้
- ติดต่อสื่อสารกับระบบอื่นๆได้
- เหมาะแก่การประมวลผล เพื่อออก report
- กำหนดสิทธิ์ผู้ใช้ (ACL)
- รองรับ Template
- Performance
เลยมาทำ research ตัว Drupal ดู สรุปได้ความดังนี้
โดยรวม
=======
- เป็น web app
- GNU GPL = นำมาใช้งานได้ฟรี
- เป็น php
- รองรับทั้ง postgres, mysql
(บาง module เช่น http://drupal.org/project/data รองรับเฉพาะ mysql)
(ใน D7 มีแยก layer ออกเป็น database abstraction
ทำให้ module ต่างๆ ไม่ต้องเขียนแยกสำหรับแต่ละ db อีกต่อไป)
- มีเอกสารพอสมควร (เพราะเป็นที่นิยม และมีผู้ใช้เยอะ)
- มี User Interface ให้ admin กำหนดสิทธิ์ + นิยามใหม่ได้โดยง่าย
รวมถึง รองรับ OpenID และ OAuth
- รองรับ Template
- มีระบบ cache (ซึ่งกำหนดได้หลายระดับ) เพื่อเพิ่ม Performance
(ไว้ทำ Project เสร็จคงให้รายละเอียดได้ว่าช้าแค่ไหน tune ยังไง)
สร้าง app ได้โดยง่าย?
===================
เนื่องจาก Drupal เริ่มต้นถูกสร้างขึ้นเพื่อเป็น CMS
ทำงานหลักๆของ app เช่น ทำหน้าหน้า Search และแสดงข้อมูล
แล้วก็ Insert, Update, Delete นั้น
Drupal มีหน้าจอ interface ให้กดๆ
(อาจจะกินเวลาในขั้นตอนตั้งชื่อตัวแปรบ้าง)
ก็จะได้หน้าผลลัพธ์ออกมาแล้ว !!!
โดยทั่วไป เมื่อพูดถึง CMS เราจะนึกถึงข้อมูลเพียง topic + body
(เช่น blog, news, forum) แล้วก็ส่วน comment
เลยสงสัยว่าด้วย drupal เราจะสร้างเนื้อหา (content)
หรือ ประเภทของเนื้อหา (content type) ที่มี field เพิ่มเติมตามความต้องการได้หรือ
(เช่น เนื้อหาประเภทหนังสือ มี isbn, ราคา, จำนวนหน้า เป็นต้น)
คำตอบคือ http://drupal.org/project/cck คือผู้อยู่เบื้องหลังคุณสมบัตินี้ครับ
(ซึ่งมีคุณสมบัติในส่วน ย้ายโครงสร้างข้อมูลที่กำหนดขึ้นนี้ ไปยัง production env ด้วย)
ซึ่งเราสามารถ config ให้ Validate input data
แล้ว drupal จะคอยตรวจสอบ + แสดงผลเตือนผู้ใช้ให้
เราไม่ต้อง coding สำหรับความต้องการนี้
ประเภทข้อมูลแบบ email http://drupal.org/project/email
หรือ ผูกรูปภาพเข้ากับ recode ในฐานข้อมูล http://drupal.org/project/imagefield
fields for content types that can be used to display video, image, and audio files from various third party providers (such as youtube) http://drupal.org/project/emfield
ตัวอย่าง วิธีทำหน้า Search criteria โดยไม่ต้อง code
http://itshee.exteen.com/20090608/views-drupal
http://civicactions.com/blog/2009/apr/28/views_filter_blocks_drupal_6
ซึ่งตัว search result สามารถกำหนดให้แสดงผลเป็นตาราง
+ build-in ส่วน next prev last ในกรณีที่ผลลัพธ์มากกว่า 1 หน้า
+ ผู้ใช้สามารถกดตาม column ต่างๆ ให้เรียงลำดับข้อมูลมากน้อยได้
หรือ แสดงผลการค้นหาแบบ google ได้
กำหนดรูปแบบการแสดงผลข้อมูล http://drupal.org/project/contemplate
ตอน research อยู่, สงสัยอยู่ว่า cms ส่วนมากจะเป็นเหมือน blog
คือจะมี content หลัก แล้วก็ comment
เราสามารถ content มาลิงค์ความสัมพันธ์แบบ foriegn key ไปยังอีก content ได้หรือ
โดยที่ content อาจจะเป็นคนละ content type กันเช่น
content ประเภทอัลบั๊มเพลง สัมพันธ์กับ content type ชื่อเพลง
ได้คำตอบว่า http://drupal.org/project/cck ในส่วน nodereference ทำในส่วนนี้ได้
(ย้ายไปอยู่ในส่วน code module แล้วใน D7)
extension
==========
Drupal มี module ให้ download และติดตั้งเพื่อเพิ่มส่วนขยายได้อย่างง่ายดาย
ตัวอย่างวิธีการ http://drupal.org/node/587878
เป็นการใช้ module lightbox ที่ทำให้เมื่อเรากดที่รูป ระบบจะแสดงรูปในแบบ fullscreen
ผู้ใช้เลื่อนดูรูปก่อนหน้า หรือถัดไปได้ (เหมือนใน facebook) หรือเป็น slide show ก็ได้
(ไม่ต้อง coding ใดๆ อีกเช่นเคย)
ซึ่งเราสามารถเขียน code สร้าง module เพิ่มเติมสำหรับงานใน app ของเราได้เช่นกัน
(Thai version - http://www.thaitux.info/node/426)
หน้าเก็บค่า config ของ module นี่ เขียน code น้อยมาก
ตัวอย่างการเขียน page ที่บันทึกข้อมูลลง db เมื่อผู้ใช้กรอกและกดปุ่ม submit
http://coderepositories.blogspot.com/2011/02/drupal-module-inset-data.html
อ่านต่อ
เราคาดหวังอะไรจาก framework บ้าง?
================================
- เป็น web app
- ฟรี ไม่ติดเรื่องลิขสิทธิ์
- ภาษา เป็น php น่าจะดี
(เพื่อเลี่ยงปัญหาลิขสิทธิ์ java หรือความไม่แน่นอนใดๆ ที่อาจจะเกิดขึ้น)
- รองรับ postgres, mysql
- มีเอกสารเพียงพอ
- ควรอำนวยความสะดวก ในสร้าง app
(ทำงานหลักๆของ app คงไม่พ้น หน้า Search และแสดงข้อมูล
แล้วก็ Insert, Update, Delete)
framework ควรเอื้อให้พัฒนาได้อย่างเร็วๆ (เช่น Validate input data)
เคยใช้ oracle application express (APEX) สร้าง App
ให้อารมณ์เหมือน ทำ M$ Access
(คือ click ๆๆๆ แล้ว key code นิดหน่อย แล้วได้ เป็น app ขึ้นมาใช้งาน)
แต่ต่างจาก access ตรงที่หน้าจอ User Interface เป็น Web
ถ้า framework เอื้อให้ทำได้อย่าง APEX นี่จะดีมาก
- เพิ่มส่วนขยายได้
เช่น อยากเพิ่ม lib ของ AJAX, JSON, JQuery, etc.
framework ก็เอื้อให้สามารถทำได้
(ถ้าไม่ได้พร้อมใช้ ก็ขอให้มีตัวอย่างคนที่ทำสำเร็จมาแล้ว
ไม่ต้องไล่แก้ code เพื่อเพิ่มเติม module ต่างๆ)
- เขียน code เพิ่มเติมสำหรับงานใน app ของเราได้
- Import Initial data ได้
- ติดต่อสื่อสารกับระบบอื่นๆได้
- เหมาะแก่การประมวลผล เพื่อออก report
- กำหนดสิทธิ์ผู้ใช้ (ACL)
- รองรับ Template
- Performance
เลยมาทำ research ตัว Drupal ดู สรุปได้ความดังนี้
โดยรวม
=======
- เป็น web app
- GNU GPL = นำมาใช้งานได้ฟรี
- เป็น php
- รองรับทั้ง postgres, mysql
(บาง module เช่น http://drupal.org/project/data รองรับเฉพาะ mysql)
(ใน D7 มีแยก layer ออกเป็น database abstraction
ทำให้ module ต่างๆ ไม่ต้องเขียนแยกสำหรับแต่ละ db อีกต่อไป)
- มีเอกสารพอสมควร (เพราะเป็นที่นิยม และมีผู้ใช้เยอะ)
- มี User Interface ให้ admin กำหนดสิทธิ์ + นิยามใหม่ได้โดยง่าย
รวมถึง รองรับ OpenID และ OAuth
- รองรับ Template
- มีระบบ cache (ซึ่งกำหนดได้หลายระดับ) เพื่อเพิ่ม Performance
(ไว้ทำ Project เสร็จคงให้รายละเอียดได้ว่าช้าแค่ไหน tune ยังไง)
สร้าง app ได้โดยง่าย?
===================
เนื่องจาก Drupal เริ่มต้นถูกสร้างขึ้นเพื่อเป็น CMS
ทำงานหลักๆของ app เช่น ทำหน้าหน้า Search และแสดงข้อมูล
แล้วก็ Insert, Update, Delete นั้น
Drupal มีหน้าจอ interface ให้กดๆ
(อาจจะกินเวลาในขั้นตอนตั้งชื่อตัวแปรบ้าง)
ก็จะได้หน้าผลลัพธ์ออกมาแล้ว !!!
โดยทั่วไป เมื่อพูดถึง CMS เราจะนึกถึงข้อมูลเพียง topic + body
(เช่น blog, news, forum) แล้วก็ส่วน comment
เลยสงสัยว่าด้วย drupal เราจะสร้างเนื้อหา (content)
หรือ ประเภทของเนื้อหา (content type) ที่มี field เพิ่มเติมตามความต้องการได้หรือ
(เช่น เนื้อหาประเภทหนังสือ มี isbn, ราคา, จำนวนหน้า เป็นต้น)
คำตอบคือ http://drupal.org/project/cck คือผู้อยู่เบื้องหลังคุณสมบัตินี้ครับ
(ซึ่งมีคุณสมบัติในส่วน ย้ายโครงสร้างข้อมูลที่กำหนดขึ้นนี้ ไปยัง production env ด้วย)
ซึ่งเราสามารถ config ให้ Validate input data
แล้ว drupal จะคอยตรวจสอบ + แสดงผลเตือนผู้ใช้ให้
เราไม่ต้อง coding สำหรับความต้องการนี้
ประเภทข้อมูลแบบ email http://drupal.org/project/email
หรือ ผูกรูปภาพเข้ากับ recode ในฐานข้อมูล http://drupal.org/project/imagefield
fields for content types that can be used to display video, image, and audio files from various third party providers (such as youtube) http://drupal.org/project/emfield
ตัวอย่าง วิธีทำหน้า Search criteria โดยไม่ต้อง code
http://itshee.exteen.com/20090608/views-drupal
http://civicactions.com/blog/2009/apr/28/views_filter_blocks_drupal_6
ซึ่งตัว search result สามารถกำหนดให้แสดงผลเป็นตาราง
+ build-in ส่วน next prev last ในกรณีที่ผลลัพธ์มากกว่า 1 หน้า
+ ผู้ใช้สามารถกดตาม column ต่างๆ ให้เรียงลำดับข้อมูลมากน้อยได้
หรือ แสดงผลการค้นหาแบบ google ได้
กำหนดรูปแบบการแสดงผลข้อมูล http://drupal.org/project/contemplate
ตอน research อยู่, สงสัยอยู่ว่า cms ส่วนมากจะเป็นเหมือน blog
คือจะมี content หลัก แล้วก็ comment
เราสามารถ content มาลิงค์ความสัมพันธ์แบบ foriegn key ไปยังอีก content ได้หรือ
โดยที่ content อาจจะเป็นคนละ content type กันเช่น
content ประเภทอัลบั๊มเพลง สัมพันธ์กับ content type ชื่อเพลง
ได้คำตอบว่า http://drupal.org/project/cck ในส่วน nodereference ทำในส่วนนี้ได้
(ย้ายไปอยู่ในส่วน code module แล้วใน D7)
extension
==========
Drupal มี module ให้ download และติดตั้งเพื่อเพิ่มส่วนขยายได้อย่างง่ายดาย
ตัวอย่างวิธีการ http://drupal.org/node/587878
เป็นการใช้ module lightbox ที่ทำให้เมื่อเรากดที่รูป ระบบจะแสดงรูปในแบบ fullscreen
ผู้ใช้เลื่อนดูรูปก่อนหน้า หรือถัดไปได้ (เหมือนใน facebook) หรือเป็น slide show ก็ได้
(ไม่ต้อง coding ใดๆ อีกเช่นเคย)
ซึ่งเราสามารถเขียน code สร้าง module เพิ่มเติมสำหรับงานใน app ของเราได้เช่นกัน
(Thai version - http://www.thaitux.info/node/426)
หน้าเก็บค่า config ของ module นี่ เขียน code น้อยมาก
ตัวอย่างการเขียน page ที่บันทึกข้อมูลลง db เมื่อผู้ใช้กรอกและกดปุ่ม submit
http://coderepositories.blogspot.com/2011/02/drupal-module-inset-data.html
อ่านต่อ
Labels:
drupal
Subscribe to:
Comments (Atom)