node.tpl.php แยกตาม type

  • warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1005 is not allowed to access /tmp owned by uid 0 in /var/www/sites/sugree/codenone.com/subdomains/www/html/includes/file.inc on line 190.
  • warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1005 is not allowed to access /tmp owned by uid 0 in /var/www/sites/sugree/codenone.com/subdomains/www/html/includes/file.inc on line 190.

จริงๆ จะถามคุณ sugree แต่ถามใน forum ดีกว่า คนอื่นจะได้ประโยชน์

เราสามารถเลือกแสดงโครงสร้างของ node แตกต่างกันตามแต่ละ content type ได้หรือเปล่า ง่ายๆ คือ node.tpl.php สำหรับ story และ forum topics ไม่เหมือนกัน

sugree's picture

ได้แน่นอนที่สุด มันจะดูจากชื่อไฟล์เป็นหลัก เช่น

  • node-blog.tpl.php
  • node-story.tpl.php
  • node-page.tpl.php
  • node-forum.tpl.php

ถ้าไม่เจอถึงจะมาใช้ node.tpl.php

jrp13th's picture

รวมถึง content type ที่เราสร้างเองจาก CCK ด้วยหรือไม่ครับ
เช่น ผมไปสร้าง content type ชื่อ articles ก็จะใช้ node-articles.tpl.php ??

โดยต้องเอาสำคัญที่่ชื่อที่่เป็น The machine-readable name ???

sugree's picture

ใช่ครับ machine-readable

mk's picture

โอ้ ไม่เคยรู้มาก่อน

arthuran's picture

เหมือนกัน ^^"

-----------
http://arthuran.net

ไม่ต้องห่วงเอกพจน์-พหูพจน์ ใช่มั้ยครับ =_=

sugree's picture

ขึ้นกับชื่อโมดูลครับ

อีกนิดนึงครับ แล้วถ้าจะให้ node.tpl เปลี่ยนไปตามโมดูลทำได้มั้ยครับ

คือ node template ที่หน้าแรก(front page)
ไม่เหมือนกับในหน้าเนื้อหา(node page)อ่ะครับ content type ชนิดเดียวกัน

sugree's picture

มีตัวแปรให้เช็คสองตัว $teaser กับ $page เอาไว้บอกว่าเป็น teaser หรือ full และ page หรือ node ตามลำดับ

ใช้ if...else กันบานเลย แฮะๆ ขอบคุณสำหรับคำแนะนำครับ

jrp13th's picture

เป็นตัวแปรที่อยากทราบอยู่พอดีครับ

ขอบคุณครับ

ย้าย Codenone

ประกาศย้าย Codenone ไปใช้ Forum ของ Blognone แทนครับ ตามไปตั้งกระทู้ต่อได้ที่ Codenone Forum (รายละเอียดอ่านจากกระทู้ ย้าย Codenone ไปรวมกับ Blognone)

กระทู้เก่าๆ จะย้ายตามไปในภายหลัง ตอนนี้ปิดการโพสต์กระทู้ไว้ เหลือไว้เฉพาะอ้างอิงเท่านั้น