Tutorial 2x Phrase Replacements - Thay thế Phrase cho XenForo 2

PVS

Generalissimo
Thành viên BQT
Tham gia
28/02/2015
Bài viết
15,966
Được Like
12,454
Phrase Replacements - Thay thế Phrase cho XenForo 2

Nếu bạn đã tìm cách thay thế các phrase khác nhau trong XenForo và cảm thấy thất vọng vì không có chức năng "tìm kiếm và thay thế". Hướng dẫn đơn giản này sẽ giúp thực hiện điều đó, không có cách nào tối ưu hóa nhưng nó thực hiện công việc trong tầm tay.

Script hơi tẻ nhạt và bạn sẽ cần mở Development Tools, sau đó điều hướng đến khu vực 'console'.

Vui lòng đọc đoạn code bên dưới để được hướng dẫn sử dụng, đây là đoạn code đầy đủ bạn sẽ chỉnh sửa.
Mã:
for(el of document.querySelectorAll('[name=phrase_text]')) {
    var text = el.innerHTML;

    var fullPhrase = "";
    var words = text.split(" ");

    for(i = 0; i < words.length; i++) {
        var word = words[i];

        if(!word.includes("{") || !word.includes("}")) {
            word = word.replace("Oldword", "Newword");
            word = word.replace("oldword", "newword");
        }

        if(i == words.length) {
            fullPhrase+=word;
        } else {
            fullPhrase+=word + " ";
        }
    }

    el.innerHTML = fullPhrase;
    console.log(fullPhrase);
}


for(btn of document.querySelectorAll("button[class*=button--icon--save]")) {
    btn.click();
}

Lý tưởng nhất là bạn sẽ chỉ tập trung vào phần sau:
Mã:
        if(!word.includes("{") || !word.includes("}")) {
            word = word.replace("Oldword", "Newword");
            word = word.replace("oldword", "newword");
        }

Điều hướng đến https://yourboardurl.com/admin.php?phrases/search, chọn addon bạn muốn thay thế, nhấp vào "Refine Search" và nhấp vào dịch.

Bạn có thể nhập bao nhiêu từ thay thế bạn muốn, ví dụ: nếu muốn thay thế "Resource", "Resources" thành "Product", "Products" bạn sẽ nhập:
Mã:
        if(!word.includes("{") || !word.includes("}")) {
            word = word.replace("Resource", "Product");
            word = word.replace("Resources", "Products");
        }

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


Nguồn: xenforo.com​
 

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

XenForo 1 XenForo 2
Translate by PVS

Hỗ trợ trực tuyến

Support Quảng cáo
Mr. San (PVS)

Skype chat, instant message

Mr. Tuấn (Blue)

Skype chat, instant message

Mr. Tuấn
0988 488 096
Mr. Trọng
0906 081 284
kinhdoanh@vnxf.vn

Nhà Tài Trợ

Mút Xốp Không Gian
pallet Thịnh Phát
Điện Lạnh Thịnh Phát
Top Bottom