Help Tự code 1 add-ons

Discussion in 'Addon, Styling and Customization Questions' started by Kuuhaku, Aug 20, 2017.

  1. Kuuhaku

    Kuuhaku Thượng Đế

    Joined:
    Jul 9, 2017
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Male
    Mình đang muốn tự code 1 add-ons kiểu chức năng là hiển thị các chủ đề có tiền tố (Thread Prefixes) nhất định
    Mình đã tạo các file Model, ControlPublic, Route/Prefix cũng như Templates.
    Đây là code file Model:
    Code:
    _getDb()->fetchAll("
                SELECT *
                FROM xf_thread
                WHERE node_id = '11' AND (prefix_id = '1' OR prefix_id = '2' OR prefix_id = '3')
                ORDER BY thread_id
                ASC
    
            ");
    
        }
    }
    Code file ở đường dẫn ControlPublic/file:php
    Code:
    ?php
    
    class Name_ControllerPublic_Home extends XenForo_ControllerPublic_Abstract
    {
        protected function getdata()
        {
            return $this->getModelfromCache('Name_Model_Model');
    
        }
    
        public function actionIndex()
        {
           $thread = '';
    
           $abc = array (
                'threadinfo' => $this->getdata()->getAllThread($thread)
                );
    
            return $this->responseView('Name_ViewPublic_Home', 'Name_Home', $abc);
        }
    }
    còn đây là hiển thị ở template:
    Kết quả thu được nó chỉ hiện 1 chủ đề có tiền tố trong khi chuyên mục đó có tận 3,4 chủ đề có tiền tố lận. ai biết lý do sao k ạ chỉ mình với, cảm ơn nhiều ạ
     
  2. Kuuhaku

    Kuuhaku Thượng Đế

    Joined:
    Jul 9, 2017
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Male
  3. Blue

    Blue Admin - Founder Staff Member

    Joined:
    Feb 25, 2015
    Messages:
    796
    Likes Received:
    1,246
    Trophy Points:
    93
    Gender:
    Male
    Bạn nghiên cứu thêm foreach ở template nhé (có rất nhiều template có chữ foreach, search sẽ thấy)
     
  4. Kuuhaku

    Kuuhaku Thượng Đế

    Joined:
    Jul 9, 2017
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Male
    của mình chỉ cần sửa code dùng foreach ở template là xong hả ad, mình có thử dùng r mà bị lỗi nó lặp lại đúng 1 chủ đề nhiều lần.
    mình k hiểu rõ cách dùng lắm ad có thể fix dumgf mình code template trên = foreach ví dụ đc k
     
    Last edited: Aug 20, 2017
  5. Kuuhaku

    Kuuhaku Thượng Đế

    Joined:
    Jul 9, 2017
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Male
  6. Kuuhaku

    Kuuhaku Thượng Đế

    Joined:
    Jul 9, 2017
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Male
    chấm chám
     
  7. Blue

    Blue Admin - Founder Staff Member

    Joined:
    Feb 25, 2015
    Messages:
    796
    Likes Received:
    1,246
    Trophy Points:
    93
    Gender:
    Male
    Bạn tự nghiên cứu mới hiểu được, cái này rất khó hướng dẫn.
     
  8. Kuuhaku

    Kuuhaku Thượng Đế

    Joined:
    Jul 9, 2017
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Male
    vậy cho mình hỏi mấy cái giá trị của loop với value nó lấy ở đâu vậy?? ví dụ loop = "$threads" value="$thread" ý.
     

Share This Page