หน้าเว็บ

วันอาทิตย์ที่ 31 มกราคม พ.ศ. 2559

วิธีแก้ไขเรียง articles ใน backend Joomla 3 - 4 ขึ้นไป

เพื่อให้สะดวกต่อการทำงาน admin ที่ดูแลเว็บไซต์หลายท่าน อาจมองหาวิธีแก้ไข default การจัดเรียง Article ทาง backend หลังบ้าน ถึง Joomla version 3 นี้หรือต่อไป versiono 4 ก็ยังไม่รู้จะมีการตั้งค่าอะไร ตอนนี้ทำได้เพียงแต่แก้ไข file ของ Joomla 2 files ดังนี้

/administrator/components/com_content/models/forms/filter_articles.xml
- เมื่อมีการเปลี่ยนแปลง form ทาง backend ตามปรกติ ค่า default ตาม id ของ article

name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.created DESC"
>

หากต้องการเปลี่ยนแปลงตามความต้องการ เช่นให้เรียงตามวันที่สร้าง ให้เปลี่ยนจาก a.id เป็น a.created

/administrator/components/com_content/models/articles.php
- เมื่อ Login เข้าไปแล้วคลิกที่เมนู Content > Articles ตามปรกติ ค่า default ตาม id ของ article

// List state information.
//parent::populateState('a.id', 'desc');
 ของเดิมรียงตาม id
parent::populateState('a.created', 'desc');

  • //$orderCol = $this->state->get('list.ordering', 'a.id') ของเดิมรียงตาม id เปลี่ยนใหม่เป็นเรียงตามวันที่
  • //$orderDirn = $this->state->get('list.direction', 'desc');
  • $orderCol = $this->state->get('list.ordering', 'a.created');
  • $orderDirn = $this->state->get('list.direction', 'desc');

ไม่มีความคิดเห็น:

แสดงความคิดเห็น