[Hỏi đáp] xin code bài viết cùng chuyên mục cho phpbb3

  Bài viết hay nhất1
Code bài viết cùng chuyên mục này ver punbb có người share rồi nhưng em đang cần cái cho phpbb3 :( ai có share với
  Bài viết hay nhất2
Có người share rồi thì chỉ việc điều chỉnh lại các selector thôi. Không tự sửa được thì cứ quăng code lên đây để mọi người giúp.
  Bài viết hay nhất3

KirigayaKazuto wrote:Có người share rồi thì chỉ việc điều chỉnh lại các selector thôi. Không tự sửa được thì cứ quăng code lên đây để mọi người giúp.

Code được share bên vngame đây ạ ! chèn vào đầu hoặc cuối view
Code:
<script>$(function () {$.ajax({url: "/feed/?f={FORUM_ID}",success: function (a) {$(".post-entry:first").after('<ul id="cungchuyenmuc">
<a href="/f{FORUM_ID}-forum" style="font-weight: bold; margin-left: 295px">Bài viết cùng chuyên mục</a><div style="height:23px;background:url(http://i34.servimg.com/u/f34/16/03/04/56/sna-ti10.png) no-repeat center top;margin:5px 0px;margin-top: -20px"></div>');22 < $(a).find("title").length ? so = 22 : so = $(a).find("title").length;for (i = 2; i < so; i++)$('<li><span><a href="' + $(a).find("link:eq(" + i + ")").text() + '">' + $(a).find("title:eq(" + i + ")").text() + "</a></span></li>").appendTo("#cungchuyenmuc")}})});</script>

<style>
ul#cungchuyenmuc {border: 1px solid rgb(239,235,239);background-color: rgb(255,251,255);
padding: 10px 15px 10px 30px;width: 80%;height: 100%;
margin-left: 58px;margin-top: 25px;display: inline-block;}
#cungchuyenmuc li {list-style:square inside;margin-top:4px;width:50%;float:left;}
#cungchuyenmuc a {color:#333;font:12px Tahoma;}
#cungchuyenmuc a:hover {color:#ba3814;}

#cungchuyenmuc span {display:inline-block;overflow:hidden;
height:14px;width:90%;margin-bottom:-2px;}


#cungchuyenmuc li{position:relative;width:50%;list-style-type:none;height:20px;line-height:20px;counter-increment:Zzindex;float:left}


#cungchuyenmuc li:before{content:counter(Zzindex);display:block;height:16px;background:#EBEBEB;position:absolute;left:-22px;font-size:11px;top:4px;border-radius:2px;text-align:center;width:16px;color:#FFF;line-height:16px;z-index:3}#cungchuyenmuc li:after{content:" ";background:#EBEBEB;display:block;width:5px;height:5px;position:absolute;top:9px;left:-9px;transform:rotate(45deg);-ms-transform:rotate(45deg);-webkit-transform:rotate(45deg)}#cungchuyenmuc li:nth-child(3):before,#cungchuyenmuc li:nth-child(3):after{background:red}#cungchuyenmuc li:nth-child(4):before,#cungchuyenmuc li:nth-child(4):after{background:#FD5405}#cungchuyenmuc li:nth-child(5):before,#cungchuyenmuc li:nth-child(5):after{background:#FDB55A}#cungchuyenmuc li:nth-child(5) ~ li:before,#cungchuyenmuc li:nth-child(5) ~ li:after{color:#EC4403;text-shadow:0 0 2px #FFF,0 0 2px #FFF,0 0 2px #FFF,0 0 2px #FFF}
.pun .entry-content {
overflow: hidden;
padding-bottom: .8em;
width: 100%;
}
</style>
  Bài viết hay nhất4

AnChina wrote:
KirigayaKazuto wrote:Có người share rồi thì chỉ việc điều chỉnh lại các selector thôi. Không tự sửa được thì cứ quăng code lên đây để mọi người giúp.

Code được share bên vngame đây ạ ! chèn vào đầu hoặc cuối view
Code:
<script>$(function () {$.ajax({url: "/feed/?f={FORUM_ID}",success: function (a) {$(".post-entry:first").after('<ul id="cungchuyenmuc">
<a href="/f{FORUM_ID}-forum" style="font-weight: bold; margin-left: 295px">Bài viết cùng chuyên mục</a><div style="height:23px;background:url(http://i34.servimg.com/u/f34/16/03/04/56/sna-ti10.png) no-repeat center top;margin:5px 0px;margin-top: -20px"></div>');22 < $(a).find("title").length ? so = 22 : so = $(a).find("title").length;for (i = 2; i < so; i++)$('<li><span><a href="' + $(a).find("link:eq(" + i + ")").text() + '">' + $(a).find("title:eq(" + i + ")").text() + "</a></span></li>").appendTo("#cungchuyenmuc")}})});</script>

<style>
ul#cungchuyenmuc {border: 1px solid rgb(239,235,239);background-color: rgb(255,251,255);
padding: 10px 15px 10px 30px;width: 80%;height: 100%;
margin-left: 58px;margin-top: 25px;display: inline-block;}
#cungchuyenmuc li {list-style:square inside;margin-top:4px;width:50%;float:left;}
#cungchuyenmuc a {color:#333;font:12px Tahoma;}
#cungchuyenmuc a:hover {color:#ba3814;}

#cungchuyenmuc span {display:inline-block;overflow:hidden;
height:14px;width:90%;margin-bottom:-2px;}


#cungchuyenmuc li{position:relative;width:50%;list-style-type:none;height:20px;line-height:20px;counter-increment:Zzindex;float:left}


#cungchuyenmuc li:before{content:counter(Zzindex);display:block;height:16px;background:#EBEBEB;position:absolute;left:-22px;font-size:11px;top:4px;border-radius:2px;text-align:center;width:16px;color:#FFF;line-height:16px;z-index:3}#cungchuyenmuc li:after{content:" ";background:#EBEBEB;display:block;width:5px;height:5px;position:absolute;top:9px;left:-9px;transform:rotate(45deg);-ms-transform:rotate(45deg);-webkit-transform:rotate(45deg)}#cungchuyenmuc li:nth-child(3):before,#cungchuyenmuc li:nth-child(3):after{background:red}#cungchuyenmuc li:nth-child(4):before,#cungchuyenmuc li:nth-child(4):after{background:#FD5405}#cungchuyenmuc li:nth-child(5):before,#cungchuyenmuc li:nth-child(5):after{background:#FDB55A}#cungchuyenmuc li:nth-child(5) ~ li:before,#cungchuyenmuc li:nth-child(5) ~ li:after{color:#EC4403;text-shadow:0 0 2px #FFF,0 0 2px #FFF,0 0 2px #FFF,0 0 2px #FFF}
.pun .entry-content {
overflow: hidden;
padding-bottom: .8em;
width: 100%;
}
</style>

Sửa lại một chút là dùng dc thôi.

Code:
<script>$(function () {$.ajax({url: "/feed/?f={FORUM_ID}",success: function (a) {$(".postbody:first").after('<ul id="cungchuyenmuc"><a href="/f{FORUM_ID}-forum" style="font-weight: bold; margin-left: 295px">Bài viết cùng chuyên mục</a><div style="height:23px;background:url(http://i34.servimg.com/u/f34/16/03/04/56/sna-ti10.png) no-repeat center top;margin:5px 0px;margin-top: -20px"></div>');22 < $(a).find("title").length ? so = 22 : so = $(a).find("title").length;for (i = 2; i < so; i++)$('<li><span><a href="' + $(a).find("link:eq(" + i + ")").text() + '">' + $(a).find("title:eq(" + i + ")").text() + "</a></span></li>").appendTo("#cungchuyenmuc")}})});</script>

<style>
ul#cungchuyenmuc {border: 1px solid rgb(239,235,239);background-color: rgb(255,251,255);
padding: 10px 15px 10px 30px;width: 80%;height: 100%;
margin-left: 58px;margin-top: 25px;display: inline-block;}
#cungchuyenmuc li {list-style:square inside;margin-top:4px;width:50%;float:left;}
#cungchuyenmuc a {color:#333;font:12px Tahoma;}
#cungchuyenmuc a:hover {color:#ba3814;}

#cungchuyenmuc span {display:inline-block;overflow:hidden;
height:14px;width:90%;margin-bottom:-2px;}


#cungchuyenmuc li{position:relative;width:50%;list-style-type:none;height:20px;line-height:20px;counter-increment:Zzindex;float:left}


#cungchuyenmuc li:before{content:counter(Zzindex);display:block;height:16px;background:#EBEBEB;position:absolute;left:-22px;font-size:11px;top:4px;border-radius:2px;text-align:center;width:16px;color:#FFF;line-height:16px;z-index:3}#cungchuyenmuc li:after{content:" ";background:#EBEBEB;display:block;width:5px;height:5px;position:absolute;top:9px;left:-9px;transform:rotate(45deg);-ms-transform:rotate(45deg);-webkit-transform:rotate(45deg)}#cungchuyenmuc li:nth-child(3):before,#cungchuyenmuc li:nth-child(3):after{background:red}#cungchuyenmuc li:nth-child(4):before,#cungchuyenmuc li:nth-child(4):after{background:#FD5405}#cungchuyenmuc li:nth-child(5):before,#cungchuyenmuc li:nth-child(5):after{background:#FDB55A}#cungchuyenmuc li:nth-child(5) ~ li:before,#cungchuyenmuc li:nth-child(5) ~ li:after{color:#EC4403;text-shadow:0 0 2px #FFF,0 0 2px #FFF,0 0 2px #FFF,0 0 2px #FFF}
.postbody {
overflow: hidden;
padding-bottom: .8em;
width: 100%;
}
</style>

Mà cái này sao ngon bằng cái của huynh vong. Gọn nhẹ hơn nhiều, khà khà.
  Bài viết hay nhất5
Huynh quá khen, code tại hạ dài hơn mà :P
Thế này là chuẩn rồi :3
  Bài viết hay nhất6
lỗi muốn banh chành cái forum lun :( lag nữa
http://diendan.ngoinhagame.com/t3675-topic#7300
thế của huynh vong la code nào share cho ae đi ^^
  Bài viết hay nhất7
Code viết cho Invision mà viết riêng theo cấu trúc của forum.
Kết quả thì tương tự code của @markai30 vừa viết thôi.

Code:
$(function() {
    function g(a) {
        a = (new Date(a)).toString().split(/\s/);
        return a[2] + "." + {
            Jan: "01",
            Feb: "02",
            Mar: "03",
            Apr: "04",
            May: "05",
            Jun: "06",
            Jul: "07",
            Aug: "08",
            Sep: "09",
            Oct: "10",
            Nov: "11",
            Dec: "12"
        }[a[1]] + "." + a[3]
    }
    $.ajax({
        type: "GET",
        url: "/feed/?f=" + $(".nav:last").attr("href").match(/\/f(\d+)-/)[1],
        cache: !1,
        dataType: "xml",
        success: function(a) {
            a = $(a).find("item:lt(10)");
            if (1 < a.length) {
                var b = $("<div>", {
                        "class": "recommend clearfix"
                    }),
                    d = $("<ol>", {
                        "class": "olList"
                    });
                b.insertAfter(".post-contents:first");
                b.append($("<h2>", {
                    html: '<i class="fa fa-star-o"></i>&nbsp;Bài cùng chuyên mục'
                }));
                b.append(d);
                if (5 < a.length) {
                    var e = $("<ol>", {
                        "class": "olList"
                    });
                    b.append(e)
                }
                a.each(function(a, b) {
                    var c = $(b),
                        f = c.find("title").text().replace(/^\[[^\[\]]+\]/, ""),
                        c = $("<li>").append($("<a>", {
                            href: c.find("link").text(),
                            title: f,
                            text: f
                        })).append($("<span>", {
                            "class": "right",
                            text: g(c.find("pubDate").text())
                        }));
                    5 > a ? c.appendTo(d) : c.appendTo(e)
                })
            }
        },
        error: function(a) {
            console.error(a)
        }
    })
});
  Bài viết hay nhất8

Zzbaivong wrote:Code viết cho Invision mà viết riêng theo cấu trúc của forum.
Kết quả thì tương tự code của @markai30 vừa viết thôi.

Code:
$(function() {
    function g(a) {
        a = (new Date(a)).toString().split(/\s/);
        return a[2] + "." + {
            Jan: "01",
            Feb: "02",
            Mar: "03",
            Apr: "04",
            May: "05",
            Jun: "06",
            Jul: "07",
            Aug: "08",
            Sep: "09",
            Oct: "10",
            Nov: "11",
            Dec: "12"
        }[a[1]] + "." + a[3]
    }
    $.ajax({
        type: "GET",
        url: "/feed/?f=" + $(".nav:last").attr("href").match(/\/f(\d+)-/)[1],
        cache: !1,
        dataType: "xml",
        success: function(a) {
            a = $(a).find("item:lt(10)");
            if (1 < a.length) {
                var b = $("<div>", {
                        "class": "recommend clearfix"
                    }),
                    d = $("<ol>", {
                        "class": "olList"
                    });
                b.insertAfter(".post-contents:first");
                b.append($("<h2>", {
                    html: '<i class="fa fa-star-o"></i>&nbsp;Bài cùng chuyên mục'
                }));
                b.append(d);
                if (5 < a.length) {
                    var e = $("<ol>", {
                        "class": "olList"
                    });
                    b.append(e)
                }
                a.each(function(a, b) {
                    var c = $(b),
                        f = c.find("title").text().replace(/^\[[^\[\]]+\]/, ""),
                        c = $("<li>").append($("<a>", {
                            href: c.find("link").text(),
                            title: f,
                            text: f
                        })).append($("<span>", {
                            "class": "right",
                            text: g(c.find("pubDate").text())
                        }));
                    5 > a ? c.appendTo(d) : c.appendTo(e)
                })
            }
        },
        error: function(a) {
            console.error(a)
        }
    })
});

Haha share rồi. Mà hình như code này huynh mới viết đúng không. Giờ cũng chịu share rồi nhé. Mà công nhận cái storage mà huynh mách đệ. Nó hay thật, có nó sẽ giải quyết được một số vấn đề đệ đang bí đấy.
Phải rồi huynh vong. Ví dụ đệ có một key như sau.
Code:
localStorage.name = '123'

Đệ muốn hỏi phải viết sao để key name đó sẽ xóa sau một thời gian mà đệ muốn.


AnChina wrote:lỗi muốn banh chành cái forum lun :( lag nữa
http://diendan.ngoinhagame.com/t3675-topic#7300
thế của huynh vong la code nào share cho ae đi ^^

Lỗi css thôi. Chịu khó sửa tí là dc chứ gì.
  Bài viết hay nhất9
Lạc đề rồi, qua đây đi.
  Bài viết hay nhất10
Đã dùng được khi thay class post body, hì
  Bài viết hay nhất11
Cái này lỗi gì chứ lỗi CSS gì ? ai giúp với :(
  Bài viết hay nhất12
Xóa đoạn css width: 100% chỗ .postbody, và sửa lại selector trong js thành .inner > center:first:

Code:
<script>
$(function() {
    $.ajax({
        url: "/feed/?f={FORUM_ID}",
        success: function(a) {
            $(".inner > center:first").after('<ul id="cungchuyenmuc"><a href="/f{FORUM_ID}-forum" style="font-weight: bold; margin-left: 240px">Bài viết cùng chuyên mục</a><div style="height:23px;background:url(http://i34.servimg.com/u/f34/16/03/04/56/sna-ti10.png) no-repeat center top;margin:5px 0px;margin-top: -20px"></div>');
            22 < $(a).find("title").length ? so = 22 : so = $(a).find("title").length;
            for (i = 2; i < so; i++) $('<li><span><a href="' + $(a).find("link:eq(" + i + ")").text() + '">' + $(a).find("title:eq(" + i + ")").text() + "</a></span></li>").appendTo("#cungchuyenmuc")
        }
    })
});
</script>
<style>
#cungchuyenmuc{border:1px solid #efebef;background-color:#fffbff;padding:10px 15px 10px 30px;width:80%;height:100%;margin-left:58px;margin-top:25px;display:inline-block}
#cungchuyenmuc li{list-style:square inside;margin-top:4px;width:50%;float:left}
#cungchuyenmuc a{color:#333;font:12px Tahoma}
#cungchuyenmuc a:hover{color:#ba3814}
#cungchuyenmuc span{display:inline-block;overflow:hidden;height:14px;width:90%;margin-bottom:-2px}
#cungchuyenmuc li{position:relative;width:50%;list-style-type:none;height:20px;line-height:20px;counter-increment:Zzindex;float:left}
#cungchuyenmuc li:before{content:counter(Zzindex);display:block;height:16px;background:#EBEBEB;position:absolute;left:-22px;font-size:11px;top:4px;border-radius:2px;text-align:center;width:16px;color:#FFF;line-height:16px;z-index:3}
#cungchuyenmuc li:after{content:" ";background:#EBEBEB;display:block;width:5px;height:5px;position:absolute;top:9px;left:-9px;transform:rotate(45deg);-ms-transform:rotate(45deg);-webkit-transform:rotate(45deg)}
#cungchuyenmuc li:nth-child(3):before,#cungchuyenmuc li:nth-child(3):after{background:red}
#cungchuyenmuc li:nth-child(4):before,#cungchuyenmuc li:nth-child(4):after{background:#FD5405}
#cungchuyenmuc li:nth-child(5):before,#cungchuyenmuc li:nth-child(5):after{background:#FDB55A}
#cungchuyenmuc li:nth-child(5) ~ li:before,#cungchuyenmuc li:nth-child(5) ~ li:after{color:#EC4403;text-shadow:0 0 2px #FFF,0 0 2px #FFF,0 0 2px #FFF,0 0 2px #FFF}
.postbody{overflow:hidden;padding-bottom:.8em}
</style>
  Bài viết hay nhất13
Tks ad !
  Bài viết hay nhất14
You cannot reply to topics in this forum