News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Modsuz Avatar Boardindex (anasyafa son iletiler)

Started by Snrj, January 28, 2017, 05:46:17 PM

Previous topic - Next topic

Snrj

bu yöntemle extra mod ve sql sorgusu kullanmadan site anasayfasında son iletilerin yanına avatar çekmeyi gösterelim
örnek resim

temanızda veya default temanın boardindex.template.php de
bul
function template_main()
{
global $context, $settings, $options, $txt, $scripturl, $modSettings;

değiştir
function template_main()
{
global $context, $settings, $options, $txt, $scripturl, $modSettings,$memberContext;

bul
<td class="lastpost">';

/* The board's and children's 'last_post's have:
time, timestamp (a number that represents the time.), id (of the post), topic (topic id.),
link, href, subject, start (where they should go for the first unread post.),
and member. (which has id, name, link, href, username in it.) */
if (!empty($board['last_post']['id']))
echo '
<p><strong>', $txt['last_post'], '</strong>  ', $txt['by'], ' ', $board['last_post']['member']['link'] , '<br />
', $txt['in'], ' ', $board['last_post']['link'], '<br />
', $txt['on'], ' ', $board['last_post']['time'],'
</p>';
echo '
</td>

değiştir
<td class="lastpost">';

if (!empty($board['last_post']['id'])){
loadMemberData($board['last_post']['member']['id']);
loadMemberContext($board['last_post']['member']['id']);
if($memberContext[$board['last_post']['member']['id']]['avatar']['image'])
echo'', $memberContext[$board['last_post']['member']['id']]['avatar']['image'],'';
else
echo'<img class="avatar" src="'.$settings['images_url'].'/theme/default_avatar.png" alt="*" />';
echo '
<p> ', $txt['by'], ' ', $board['last_post']['member']['link'] , '<br />
<strong>', $txt['last_post'], '</strong> ', $board['last_post']['link'], '<br />
', $txt['on'], ' ', $board['last_post']['time'],'
</p>';
}
echo '
</td>

temanızın index.css de en alta ekle
.lastpost .avatar{
float:left;
width:30px;
height:30px;
border-radius:50%;
border: 1px solid #ccc;
    overflow: hidden;
}


defaul avatar için temanızın images klasörüne default_avatar.png adında bir avatar ekleyin veya ektekini atabilirsiniz
emeğe saygı başka yerlerde paylaşırken kaynak gösterelim snrj http://smf.konusal.com

Advertisement: