TEST
Bạn có muốn phản ứng với tin nhắn này? Vui lòng đăng ký diễn đàn trong một vài cú nhấp chuột hoặc đăng nhập để tiếp tục.
TEST

Hoạt động tốt trên các trình duyệt FF FireFox, Chrome Chrome, Opera Opera, Safari Safari hoặc có thể với IE Internet Explorer 8.0 trở lên...

You are not connected. Please login or register

Avatar of who last posted on the index

2 posters

Go down  Thông điệp [Trang 1 trong tổng số 1 trang]

1Avatar of who last posted on the index Empty Avatar of who last posted on the index Sun Oct 19, 2014 12:36 am

Admin

Admin
Admin

Hello everyone,

Here is a tutorial to display the avatar of the member who last posted on the index of your forum !

Avatar of who last posted on the index Captu445

Avatar of who last posted on the index Icon_exclaim ATTENTION Avatar of who last posted on the index Icon_exclaim
This will not work for members with an outdated browser


2. The Javascript code :

Administration Panel > Modules > HTML & Javascript > Javascript codes management > Create a new script :

Title : Avatar in the index
Placement : In the home page
Paste the following code and save :
Code:  Select Content
Code:
        $(function(){
         
          if(!window.localStorage) return;
         
          // Avatar by default
            var default_avatar= 'http://2img.net/i/fa/invision/pp-blank-thumb.png';
         
          // Time of cache, here : 24hrs * 60m * 60s * 1000ms so one day
            var caching_time= 24*60*60*1000;
         
          // Time of cache in case of error, here : 60s * 1000ms so one minute
            var caching_error= 60*1000;
         
          var set_avatar= function(id) {
                $('.mini_ava.member'+id).html('<img src="'+get_avatar(id)+'" />');
            };
         
          var get_avatar= function(id) {
                if(localStorage.getItem('t_ava'+id) < +new Date - caching_time || (localStorage.getItem('d_ava'+id)==default_avatar && localStorage.getItem('t_ava'+id) < +new Date - caching_error))
                {
                    localStorage.setItem('d_ava'+id, default_avatar);
                    $.get('/u'+id, function (d){
                        localStorage.setItem('t_ava'+id,+new Date);
                        localStorage.setItem('d_ava'+id, $('#profile-advanced-right .module:first div img:first,.forumline td.row1.gensmall:first > img, .frm-set.profile-view.left dd img,dl.left-box.details:first dd img, .row1 b .gen:first img, .real_avatar img',d).first().attr('src')||default_avatar);
                        set_avatar(id);
                    });
                }
                return localStorage.getItem('d_ava'+id);
            };
         
          var to_replace= {};
         
          $('dd.lastpost strong a.gensmall, .ipbtable tr td:last-child span strong a.gensmall, .table td.tcr strong a.gensmall, .forumline .row3.over strong a.gensmall').each(function(){
                to_replace[$(this).attr('href').substr(2)]= 1;
                $(this).closest('td,dd').prepend('<div class="mini_ava member'+$(this).attr('href').substr(2)+'"></div>');
            });
         
          for(i in to_replace)
            {
                set_avatar(i);
            };
         
      });


3. The CSS code :

Administration Panel > Display > Pictures and colors > Colors > CSS stylesheet

Paste the following code into your sheet and submit. This will help resize the image, and position it properly in the last post.
Code:  Select Content
Code:
.mini_ava{
float:left;
}
.mini_ava img{
width:40px;
height:40px;
margin: 0 5px;
}
You can personalize the code by adding a border, colors..

and it's finished ! Avatar of who last posted on the index 4274788354

https://tieudoitruong.forumvi.com

Panda

Panda

Phương pháp trên có điểm yếu là chỉ hiện ở diễn đàn chính:

Avatar of who last posted on the index Avatar10

Diễn đàn thứ cấp thì không hiển thị:

Avatar of who last posted on the index Avatar11

Riêng phương pháp dưới đây thì bảo đảm hiển thị tốt tại mọi vị trí:

Cài đặt: Vào ACP>>Display>>Structure & hierarchy>>Hierarchy>>"Show avatars in the column Last posts">>Yes

Avatar of who last posted on the index Show_a10

Title lenght of the last topic: 20

Avatar of who last posted on the index Title_10

Kết quả:

Avatar of who last posted on the index Last_p10

Lưu ý: Đối với các templates đã chỉnh sửa cần thay đổi cấu trúc như hướng dẫn sau để cập nhật trên có tác dụng. 

PhppBB2

Tìm trong index_box:

Code:
<span class="gensmall">{catrow.forumrow.LAST_POST}</span>

thay bằng:

Code:
<!-- BEGIN avatar -->
<div style="width: 200px;"></div>
<span class="lastpost-avatar">{catrow.forumrow.avatar.LAST_POST_AVATAR}</span>
<!-- END avatar -->

<span class="gensmall">{catrow.forumrow.LAST_POST}</span>

Tìm trong topics_list_box:

Code:
<span
class="postdetails">{topics_list_box.row.LAST_POST_TIME}<br
/>{topics_list_box.row.LAST_POST_AUTHOR}
{topics_list_box.row.LAST_POST_IMG}</span>

thay bằng:

Code:
<!-- BEGIN avatar -->
<div style="width: 200px;"></div>
<span class="lastpost-avatar">{topics_list_box.row.topic.avatar.LAST_POST_AVATAR}</span>
<!-- END avatar -->

<span
 class="postdetails">{topics_list_box.row.LAST_POST_TIME}<br
/>{topics_list_box.row.LAST_POST_AUTHOR}
{topics_list_box.row.LAST_POST_IMG}</span>

PunBB

Tìm trong index_box:

Code:
<span>
<!-- BEGIN switch_topic_title -->
<a
href="{catrow.forumrow.U_LATEST_TOPIC}"
title="{catrow.forumrow.LATEST_TOPIC_TITLE}">{catrow.forumrow.LATEST_TOPIC_NAME}</a><br
 />
<!-- END switch_topic_title -->
{catrow.forumrow.USER_LAST_POST}
</span>

thay bằng:

Code:
<!-- BEGIN avatar -->
<span class="lastpost-avatar">{catrow.forumrow.avatar.LAST_POST_AVATAR}</span>
<!-- END avatar -->

<span>
<!-- BEGIN switch_topic_title -->
<a
 href="{catrow.forumrow.U_LATEST_TOPIC}"
title="{catrow.forumrow.LATEST_TOPIC_TITLE}">{catrow.forumrow.LATEST_TOPIC_NAME}</a><br
 />
<!-- END switch_topic_title -->
{catrow.forumrow.USER_LAST_POST}
</span>

Tìm trong topics_list_box:

Code:
{topics_list_box.row.LAST_POST_TIME} {topics_list_box.row.L_BY}
{topics_list_box.row.LAST_POST_AUTHOR}
{topics_list_box.row.LAST_POST_IMG}

thay bằng:

Code:
<!-- BEGIN avatar -->
<span class="lastpost-avatar">{topics_list_box.row.topic.avatar.LAST_POST_AVATAR}</span>
<!-- END avatar -->

{topics_list_box.row.LAST_POST_TIME}
 {topics_list_box.row.L_BY} {topics_list_box.row.LAST_POST_AUTHOR}
{topics_list_box.row.LAST_POST_IMG}

Chỉnh lại CSS

Avatar of who last posted on the index 2292716413  Admin panel>>Display>>Colors>>CSS

Avatar of who last posted on the index 644535217 Nếu "Desactivate the basic CSS  Avatar of who last posted on the index Icon_arrow  YES bạn phải chỉnh lại CSS

Avatar of who last posted on the index 2343271778 Nếu "Desactivate the basic CSS  Avatar of who last posted on the index Icon_arrow  NO bạn không phải chỉnh lại CSS

Avatar of who last posted on the index Css10

VERSION LTR (css.tpl) :

Code:
.lastpost-avatar {
float: left;
padding: 2px;
}
.lastpost-avatar img {
width: 38px;
height: 38px;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}

Avatar of who last posted on the index Wnh3s3W

Nguồn: Forumotion

Về Đầu Trang  Thông điệp [Trang 1 trong tổng số 1 trang]

Permissions in this forum:
Bạn không có quyền trả lời bài viết