News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

code help

Started by gecitli, January 27, 2021, 07:44:50 AM

Previous topic - Next topic

gecitli

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>
http://www.webtiryaki.com
webmaster forumu
Free & Premium Responsive Themes for SMF.

Kindred

add this to see the entire array....

echo '<pre>'; print_r($widgetposts); echo '</pre>';
Сл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."

gecitli

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.
http://www.webtiryaki.com
webmaster forumu
Free & Premium Responsive Themes for SMF.

Kindred

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
Сл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."

gecitli

got it Kindred thank you.
http://www.webtiryaki.com
webmaster forumu
Free & Premium Responsive Themes for SMF.

Advertisement: