Matchbox 0.9.4 URI

Matchbox Ref: http://code.google.com/p/matchbox/

ผมตั้งชื่อ Module กับชื่อ Controller ใน Module เป็นชื่อเดียวกันครับ ก็เลยเกิดข้อผิดพลาดในการ parse route ตอนแรกก็เข้าใจว่าเป็น Bug ของ Matchbox ครับ. แต่จริงๆ แล้วไม่ใช่ครับ เป็นความจงใจของ Zacharias Knudsen เค้าครับ

มีกฎดังนี้ครับ
www.example.com/module/controller/method/parameter

  1. The first segment represents the module in which the controller can be found.
  2. The second segment represents the controller that should be invoked.
  3. The third segment represents the method that should be called.
  4. The fourth, and any additional segments, represents the variables that will be passed to the controller.

และมีเงื่อนไขดังนี้

  1. If the controller is located in a subfolder then the subfolder must be added as another segment between the module and controller segments.
    (ถ้า controller อยู่ใน subfolder ให้ใส่ subfolder ไปใน URI ด้วย ตรงระหว่าง module กับ controller อันนี้ค่อนข้าง make sence ครับ ไม่มีอะไรมาก)
  2. If the controller have the same name as the module, the controller segment can be omitted.
    (ถ้า controller ชื่อเดียวกับ module ให้ละชื่อ controller ใน URI ครับ ก็จะกลายเปน www.example.com/module/method/parameter)
  3. If the controller is in a subfolder and have the same name as the subfolder, the controller segment can be omitted.
    (ถ้า controller ชื่อเดียวกับ subfolder ให้ละชื่อ controller ใน URI )

แล้วถ้า module, subfolder และ controller ชื่อเดียวกันหมดละ!?

อันนี้ผมทำการทดลองให้แล้วครับ ก็คือให้ละชื่อ controller เช่นเดิมครับ โดยจะต้องระบุ module และ subfolder ไว้ใน URI

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.