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

PVS

Super Moderator
Thành viên BQT
Tham gia
28/02/2015
Bài viết
16,829
Được Like
12,690
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

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