Other Thêm văn bản xem trước cho bài viết đầu tiên trong thread list

PVS

Super Moderator
Thành viên BQT
Tham gia
28/02/2015
Bài viết
16,829
Được Like
12,687
Thêm văn bản xem trước cho bài viết đầu tiên trong thread list

Vào library/XenForo/ControllerPublic/Forum.php

Tìm:
Mã:
'join' => XenForo_Model_Thread::FETCH_USER

Thay bằng:
Mã:
'join' => XenForo_Model_Thread::FETCH_USER | XenForo_Model_Thread::FETCH_FIRSTPOST,

Tiếp theo vào library/XenForo/ViewPublic/Forum/View.php

Thêm vào đoạn code màu đỏ:
Mã:
    /**
     * Help render the HTML output.
     *
     * @return mixed
     */
    public function renderHtml()
    {
        $this->_params['renderedNodes'] = XenForo_ViewPublic_Helper_Node::renderNodeTreeFromDisplayArray(
            $this, $this->_params['nodeList'], 2 // start at level 2, which means only 1 level of recursion
        );


        // RENDER FIRST POSTS
        $previewLength = XenForo_Application::get('options')->discussionPreviewLength;

        foreach ($this->_params['threads'] AS &$thread)
        {
            if ($previewLength && !empty($thread['message']))
            {
                $formatter = XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_Text');
                $parser = XenForo_BbCode_Parser::create($formatter);

                $thread['messageParsed'] = $parser->render($thread['message']);
            }
        }
    }

Nhìn ảnh bên dưới để xác dịnh đoạn code màu đỏ:

1.png

Đến Admin CP -> Appearance -> Templates -> thread_list_item

Tìm:
Mã:
<div class="secondRow">

Thêm vào bên dưới nó đoạn code sau:
Mã:
<div class="text">
                    <blockquote>{xen:string nl2br, {xen:helper wordtrim, $thread.messageParsed, $xenOptions.discussionPreviewLength}}</blockquote>
                </div>

Kết quả là một đoạn văn bản ngắn xem trước của bài viết đầu tiên của chủ đề được hiển thị trong danh sách chủ đề:

2.png

Chúc các bạn thành công.


Nguồn: xenforo.com​
 
  • Like
Reactions: THB

Hướng dẫn sử dụng

XenForo 1 XenForo 2
Translate by PVS

Dịch vụ XenForo của VNXF

Mobile/Zalo: 0906081284

Telegram: anhanhxf

Chỉ nhận web nội dung lành mạnh

Nhà Tài Trợ

Mút Xốp Không Gian
Mút Sofa Không Gian
Top Bottom