Top Poster integration in Homepage

Started by SychO, August 30, 2015, 05:43:09 PM

Previous topic - Next topic

SychO

Hello everyone,

so here is the thing, i have put a top posters box in my homepage (not portal)

but its different from what it is in the portal ! it only shows the name of those top posters and i want the avatar of the members as well

so is it possible ?

<?php ssi_topPoster(); ?>
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

Kindred

avatar is not one of the data points pulled by the SSI function.
these are the only things that it pulls
         'id' => $row['id_member'],
         'name' => $row['real_name'],
         'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
         'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
         'posts' => $row['posts']


So, you would have to write your own code...
(moving to coding, as this is beyond standard support)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

SychO

#2

please i'm not much of a coder in php i just want it to look like simplePortal's top posters block.
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

Pipke

This only can be done by 2 ways, add a extra joins on the query in the ssi.php file or with the global $memberContext with the foreach.

look at this topic to get an idea with $memberContext.

"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

SychO

well looking that i have no experience at php :3

and looking into the 1st way :

i added to the function ssi_topPoster in SSI.php  this :

'avatar' => '<img src="' . $scripturl . '?action=dlattach;attach=' . $row['id_member'] . ';type=avatar" />',   

xD does it even make sense ?
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

Kindred

That won't work in more than half of the avatar cases...   that ONLY works if the avatar was uploaded to the site and processed as an attachment.
If the avatar was uploaded and not processed, chosen from the list of existing avatars, chosen as a URL, etc.... that URL won't work
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

SychO

I tried it and doesn't work in every cases of avatars
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

Kindred

yup... which is what I said would happen... :P
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Pipke

edit to this in the SSI.php in function ssi_topPoster


global $db_prefix, $scripturl, $smcFunc, $modSettings;

// Find the latest poster.
$request = $smcFunc['db_query']('', '
SELECT m.id_member, m.real_name, m.posts, m.avatar,
IFNULL(av.id_attach, 0) AS id_attach, av.filename, av.attachment_type
FROM {db_prefix}members AS m
LEFT JOIN {db_prefix}attachments AS av ON (av.id_member = m.id_member)
ORDER BY posts DESC
LIMIT ' . $topNumber,
array(
)
);
$return = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$return[] = array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
'posts' => $row['posts'],
'avatar' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),

);
$smcFunc['db_free_result']($request);
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

Kindred

In general, we discourage direct edits to SSI.php --- it is usually better to use the existing SSI functions and then ADD your own queries after the function sends the OUTPUT
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: