How do I include hello person avatar in code?
$array = ssi_recentPosts(5, null, null, 'array');
echo '
<div class="p-4 space-y-4">
<ul class="sonileti">';
foreach ($array as $widgetposts)
echo '
<li class="block-row">
<div class="contentRow">
<span class="d-block text-dark text-capitalize text-truncate mw-150p">', $widgetposts['link'], '</span>
', $txt['by'], ' ', $widgetposts['poster']['link'], ' (', $widgetposts['board']['link'], ')
</div>
</li>';
echo '
</ul>
</div>
add this to see the entire array....
echo '<pre>'; print_r($widgetposts); echo '</pre>';
Quote from: Kindred on January 27, 2021, 09:57:27 AM
add this to see the entire array....
echo '<pre>'; print_r($widgetposts); echo '</pre>';
I'm sorry I don't understand the logic of getting a print?
$array = ssi_recentPosts(5, null, null, 'array');
loadMemberData(array_map(function($post) {
return $post['poster']['id'];
}, $context['latest_posts']));
echo '
<div class="p-4 space-y-4">
<ul class="sonileti">';
foreach ($array as $widgetposts)
loadMemberContext($post['poster']['id']);
if (!empty($post['poster']['id']))
$avatar = $GLOBALS['memberContext'][$post['poster']['id']]['avatar'];
else
$avatar = array('image' => '<img class="avatar" src="'.$GLOBALS['modSettings']['avatar_url'] . '/default.png'.'" alt="avatar">');
echo '
<li class="block-row">
<div class="contentRow">
<div class="poster-avatar">', $avatar['image'], '</div>
<span class="d-block text-dark text-capitalize text-truncate mw-150p">', $widgetposts['link'], '</span>
', $txt['by'], ' ', $widgetposts['poster']['link'], ' (', $widgetposts['board']['link'], ')
</div>
</li>';
echo '
</ul>
</div>
It doesn't have to be like this
I can set these codes as how they work.
you asked "how do I get the avatar to display"?
I provided a line of code that, when triggers, shows you the entire array including every variable that you can use within that array...
it's a debugging thing that you can use to find out the proper variable name(s).
however, $avatar['image'] is not valid.... $avatar is not an array - it's a single variable, so calling the sub-variable as if it was an array won't work.
also $post['poster']['id']??
just before that, you said: foreach ($array as $widgetposts)
so you should be working with the $widgetposts[...] array variable
plus, I don't think that you need to loadmembercontext....
like I said -- do the print_r to find out what variables are included in the array already
got it Kindred thank you.