display avy in ssi_boardNews

Started by diplomat., January 06, 2005, 05:21:31 PM

Previous topic - Next topic

diplomat.

is it possible to display the avatar of the person who made the topic along with the topic body of ssi_boardNews? i made a little example:



can the avy or the topic author be pulled so that it shows up on the page sort of like that
avidSOUND.com: Where Aspiring Musicians Can Be HEARD!

[Unknown]

Sorry for taking so long to respond.

It's possible, but it could take some modification...

From SSI.php:
SELECT
m.icon, m.subject, m.body, IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime,
t.numReplies, t.ID_TOPIC, m.ID_MEMBER, m.smileysEnabled
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE t.ID_BOARD = $board
AND m.ID_MSG = t.ID_FIRST_MSG
ORDER BY m.ID_MSG DESC
LIMIT $start, $limit", __FILE__, __LINE__);


Make that:
SELECT
m.icon, m.subject, m.body, IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime,
t.numReplies, t.ID_TOPIC, m.ID_MEMBER, m.smileysEnabled, mem.avatar, a.ID_ATTACH
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
LEFT JOIN {$db_prefix}attachments AS a ON (a.ID_MEMBER = m.ID_MEMBER)
WHERE t.ID_BOARD = $board
AND m.ID_MSG = t.ID_FIRST_MSG
ORDER BY m.ID_MSG DESC
LIMIT $start, $limit", __FILE__, __LINE__);


Not much later, after:
$row['body'] = doUBBC($row['body'], $row['smileysEnabled']);

Add:
if (stristr($row['avatar'], 'http://') && !empty($modSettings['avatar_check_size']))
{
$sizes = url_image_size($row['avatar']);

// Does your avatar still fit the maximum size?
if ($modSettings['avatar_action_too_large'] == 'option_refuse' && is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external']))))
{
// Fix it permanently!
$row['avatar'] = '';
updateMemberData($row['ID_MEMBER'], array('avatar' => '\'\''));
}
}


And then find:
'is_last' => false

Make that:

'is_last' => false,
'avatar' => array(
'name' => &$row['avatar'],
'image' => $row['avatar'] == '' ? ($row['ID_ATTACH'] > 0 && !empty($modSettings['avatar_allow_upload']) ? '<img src="' . $scripturl . '?action=dlattach;id=' . $row['ID_ATTACH'] . ';type=avatar" alt="" />' : '') : (stristr($row['avatar'], 'http://') && !empty($modSettings['avatar_allow_external_url']) ? '<img src="' . $row['avatar'] . '"' . ($modSettings['avatar_action_too_large'] == 'option_html_resize' ? (!empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '') . (!empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '') : '') . ' alt="" border="0" />' : (!empty($modSettings['avatar_allow_server_stored']) ? '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" border="0" />' : '')),
'href' => $row['avatar'] == '' ? ($row['ID_ATTACH'] > 0 && !empty($modSettings['avatar_allow_upload']) ? $scripturl . '?action=dlattach;id=' . $row['ID_ATTACH'] . ';type=avatar' : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])
),


Then you have the href and image ;).

-[Unknown]

Midgard


Iriasu

#3
When I add ', $news['avatar'], ' to the place where I want to show my avatar, it just says "Array" on that spot of my news posts. The actual coding seems to work somewhat fine, but what is that small string I should write to make avatars show up on news post?

Something in the fashion of:
', $something['something'], '

Thanks in advance! ^_^

EDIT: Nevermind. I found out myself. I wrote ', $news['avatar']['image'], ' and it worked splendidly. ^^

EDIT: While I'm at the questionings, what should I do, if I want my (as an example) 100x100 avatar on my board show up on my news posts as 50x50 instead? I want the avatar to keep its original size in the board, but reduce its size on news posts.
hxxp:www.rockmanpm.com [nonactive]
Fight, Iriasu! For Everlasting Orange Fanta!
hxxp:img100.exs.cx/img100/2870/nvcdash4qs.gif [nonactive]

[Unknown]

<img src="', $news['avatar']['href'], '" width="50" height="50" alt="" />

-[Unknown]

MKava

Can somebody please update this for the latest released version of SMF?
I'm running v1.1.2 and couldn't get to this work. It'd be a real nice feature to add on just for a little more flavor to my site. :D
M. Kava
SMF Forums: Freaky Forums [nofollow] for NintendoFreaks.com [nofollow]

codenaught

Quote from: MKava on March 11, 2007, 12:47:08 AM
Can somebody please update this for the latest released version of SMF?
I'm running v1.1.2 and couldn't get to this work. It'd be a real nice feature to add on just for a little more flavor to my site. :D
MKava, still need help with this?
Dev Consultant
Former SMF Doc Coordinator

KouZeN

I'd like to see this updated for v1.1.3 if at all possible.

Ryatzu


codenaught

Code for 1.1.3 (Simply adapted from [Unknown]'s):

SSI.php

Code (Find) Select
SELECT
m.icon, m.subject, m.body, IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime,
t.numReplies, t.ID_TOPIC, m.ID_MEMBER, m.smileysEnabled, m.ID_MSG, t.locked
FROM ({$db_prefix}topics AS t, {$db_prefix}messages AS m)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE t.ID_FIRST_MSG IN (" . implode(', ', $posts) . ")
AND m.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_FIRST_MSG DESC
LIMIT " . count($posts), __FILE__, __LINE__);


Code (Replace with) Select
SELECT
m.icon, m.subject, m.body, IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime,
t.numReplies, t.ID_TOPIC, m.ID_MEMBER, m.smileysEnabled, m.ID_MSG, t.locked, mem.avatar, a.ID_ATTACH, a.attachmentType, a.filename
FROM ({$db_prefix}topics AS t, {$db_prefix}messages AS m)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
LEFT JOIN {$db_prefix}attachments AS a ON (a.ID_MEMBER = m.ID_MEMBER)
WHERE t.ID_FIRST_MSG IN (" . implode(', ', $posts) . ")
AND m.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_FIRST_MSG DESC
LIMIT " . count($posts), __FILE__, __LINE__);


Code (Find) Select
$row['body'] = parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']);

Code (After add) Select
if (stristr($row['avatar'], 'http://') && !empty($modSettings['avatar_check_size']))
{
$sizes = url_image_size($row['avatar']);

// Does your avatar still fit the maximum size?
if ($modSettings['avatar_action_too_large'] == 'option_refuse' && is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external']))))
{
// Fix it permanently!
$row['avatar'] = '';
updateMemberData($row['ID_MEMBER'], array('avatar' => '\'\''));
}
}


Code (Find (in ssi_boardNews function)  ) Select
'is_last' => false


Code (Replace above with (Code adapted from Load.php)  ) Select
'is_last' => false,
'avatar' => array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['ID_ATTACH'] > 0 ? '<img src="' . (empty($row['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $row['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($row['avatar'], 'http://') ? '<img src="' . $row['avatar'] . '" alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" class="avatar" border="0" />'),
'href' => $row['avatar'] == '' ? ($row['ID_ATTACH'] > 0 ? (empty($row['attachmentType']) ? $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']),
'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
),


Then you can use either add the variables as you wish in the template output inside the SSI function, or if not using the 'echo' return type when calling the function, you can just use the added variables as needed when outputting the news.
Dev Consultant
Former SMF Doc Coordinator

Ryatzu

ok i changed it, how can i get the avatar on the index now?

Ryatzu


mira-san

I try to make that but it doesn't work in smf 1.14
I make all the step.
Hope you can help me please.

codenaught

Quote from: mira-san on October 15, 2007, 08:42:17 AM
I try to make that but it doesn't work in smf 1.14
I make all the step.
Hope you can help me please.
Were you trying to use my code I posted?

What doesn't work about it? Could you not find all of the code that is there? Do you get parse errors? That code alone, won't show the avatar, you would need to echo out the avatar variable created with that code manually, which I can help with if I know that is the stage you are on (That you have successfully applied those code changes with no errors but don't see an avatar being displayed).
Dev Consultant
Former SMF Doc Coordinator

myaicons

@ akabugeyes

does your code work with 1.1.4?

can i get further details? Thanks!
i scratch your back you scratch my back...
funny thing about my back is its located on my...

Ryatzu

Just used it again in 1.14, works great.

myaicons

#16
Quote from: akabugeyes on November 13, 2007, 12:45:33 AM
That code alone, won't show the avatar, you would need to echo out the avatar variable created with that code manually, which I can help with if I know that is the stage you are on (That you have successfully applied those code changes with no errors but don't see an avatar being displayed).


can i get help with this?  i dont know how to make the avatar show up


this just shows a red x :

<img src="', $news['avatar']['href'], '" width="50" height="50" alt="" /> 

when i add it like this:

foreach ($return as $news)
{
echo '
<div>
<a href="', $news['href'], '">', $news['icon'], '</a> <b>', $news['subject'], '</b>
<div class="smaller">', $news['time'], ' ', $txt[525], ' ', $news['poster']['link'], '</div>
<img src="', $news['avatar']['href'], '" width="50" height="50" alt="" /> 
<div class="post" style="padding: 2ex 0;">', $news['body'], '</div>

', $news['link'], $news['locked'] ? '' : ' | ' . $news['comment_link'], '
</div>';

if (!$news['is_last'])
echo '
<hr style="margin: 2ex 0;" width="100%" />';
}
}
i scratch your back you scratch my back...
funny thing about my back is its located on my...

myaicons

i scratch your back you scratch my back...
funny thing about my back is its located on my...

[SiNaN]

Former SMF Core Developer | My Mods | SimplePortal

myaicons

tried that... still wont work for me....

any more ideas???
i scratch your back you scratch my back...
funny thing about my back is its located on my...

Advertisement: