สร้าง block region อยู่เหนือ comment ใน drupal 6


drupal 6 สามารถสร้าง block region เพิ่มเองได้อย่างง่ายๆ และเราก็จับวางไว้ส่วนไหนของหน้าเว็บก็ได้ตามต้องการ แต่คราวนี้จะมาบอกวิธีการสร้าง block region ให้อยู่ก่อนหรือเหนือ comment section

โดยผมจะเอาไว้ใช้งานร่วมกับ Similar Entries เพื่อไว้ทำ related post แบบของ wordpress นึกภาพไม่ออกก็ดูจากบล็อกผมก็ได้ครับ แต่เราก็สามารถนำ module ตัวอื่นไปวางได้นะครับ

วิธีการสร้าง block region ให้อยู่ก่อนหรือเหนือ comment section

1. เปิดไฟล์ .info ของ theme ที่เราใช้ ในที่นี้ผมใช้ theme whitejazz ชื่อไฟล์ว่า whitejazz.info เพิ่มตัวนี้เข้าไป

regions[above_comments] = Above Comments

2. เปิดไฟล์ template.php ขึ้นมาถ้าไม่มีให้สร้างใหม่แล้วเพิ่มโค็ดด้านล่างเข้าไป

function phptemplate_preprocess_node(&$variables, $hook) {
  $variables['above_comments'] = theme('blocks', 'above_comments');
}

3. เปิดไฟล์ node.tpl.php หาคำว่า

<?php print $content ?>

แล้วเพิ่มโค็ดด้านล่างต่อลงมา

<?php if ($above_comments): ?>
    <div class="above_comments"><?php print $above_comments ?></div>
<?php endif ?>

4. ไปที่เว็บ drupal ของเราแล้วไป clear cache ซะเพื่อให้เห็นผล

เสร็จแล้วเราก็ใส่ module Similar Entries เข้าไปที่ block Above Comments เป็นอันเสร็จสิ้น

via : http://www.o-learn.com/content/drupal-6-how-to-create-a-new-block-region-above-before-comments-section


Comments

คนหลงทาง's picture
goalranks
44 weeks 5 days ago

ข้อมูลคุณภาพอีกแล้ว

โอวววววว ข้อมูลเป็นประโยชน์มากมายครับ เดี๋ยวจะต้องเอาไปปรับใช้บ้างแล้ว

คนหลงทาง's picture
ball
13 weeks 2 days ago

ผมเคยลองแล้วมันดันไปอยู่ใต้

ผมเคยลองแล้วมันดันไปอยู่ใต้ comment อ่ะ  ลองใหม่ดีกว่า

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • HTML tags will be transformed to conform to HTML standards.

More information about formatting options

CAPTCHA
คำถามนี้ทดสอบว่าคุณมีความรู้ทางคณิตศาสตร์ ไม่ได้โง่!!!
5 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.