2010-12-30, 12:22 AM
In the file called: functions_post.php. Which can be found in the "inc" directory.
This code can be found starting around line: 303.
In this section of that code above, show below:
I added a default avatar to be displayed in posts for members that have not chosen one like this below.
The problem I face with though. That default avatar gets displayed in both the "classic" and "horizontal" layouts. I need to be able to add a conditional so one version of that no_avatar gets displayed in the classic layout, but another one gets shown in the horizontal layout. How can that be done with the code above, looking at this section I would presume most below.
I can see it uses an (else) statement, so I'm thinking that can be expanded upon to list two different avatars I enter. One for the classic layout and one for horizontal layout.
Just to add the reason why I need to do this. I need to display a different default "No Avatar" in the Horizontal layout, because it requires that "margin-right: 10px;" be added to the css it uses. Done so it matches the other avatars people upload and use, creating a 10 px space between the avatar on the right-side and the rank images.
The margin space cannot be added if the same avatar is also displayed in the Classic Layout. It pushed the avatar 10px over to the left side, it doesn't align center in that classic layout.
This code can be found starting around line: 303.
if($post['avatar'] != "" && ($mybb->user['showavatars'] != 0 || !$mybb->user['uid']))
{
$post['avatar'] = htmlspecialchars_uni($post['avatar']);
$avatar_dimensions = explode("|", $post['avatardimensions']);
if($avatar_dimensions[0] && $avatar_dimensions[1])
{
list($max_width, $max_height) = explode("x", my_strtolower($mybb->settings['postmaxavatarsize']));
if($avatar_dimensions[0] > $max_width || $avatar_dimensions[1] > $max_height)
{
require_once MYBB_ROOT."inc/functions_image.php";
$scaled_dimensions = scale_image($avatar_dimensions[0], $avatar_dimensions[1], $max_width, $max_height);
$avatar_width_height = "width=\"{$scaled_dimensions['width']}\" height=\"{$scaled_dimensions['height']}\"";
}
else
{
$avatar_width_height = "width=\"{$avatar_dimensions[0]}\" height=\"{$avatar_dimensions[1]}\"";
}
}
eval("\$post['useravatar'] = \"".$templates->get("postbit_avatar")."\";");
$post['avatar_padding'] = "padding-right: 10px;";
}
else
{
$post['useravatar'] = "";
}
In this section of that code above, show below:
$post['useravatar'] = "";
I added a default avatar to be displayed in posts for members that have not chosen one like this below.
$post['useravatar'] = "<a href=\"{$post['profilelink_plain']}\"><img src=\"{$mybb->settings['bburl']}/images/no_avatar.gif\" class=\"avatar_border_static\" alt=\"\" /></a>";
The problem I face with though. That default avatar gets displayed in both the "classic" and "horizontal" layouts. I need to be able to add a conditional so one version of that no_avatar gets displayed in the classic layout, but another one gets shown in the horizontal layout. How can that be done with the code above, looking at this section I would presume most below.
eval("\$post['useravatar'] = \"".$templates->get("postbit_avatar")."\";");
$post['avatar_padding'] = "padding-right: 10px;";
}
else
{
$post['useravatar'] = "<a href=\"{$post['profilelink_plain']}\"><img src=\"{$mybb->settings['bburl']}/images/no_avatar.gif\" class=\"avatar_border_static\" alt=\"\" /></a>";
}
I can see it uses an (else) statement, so I'm thinking that can be expanded upon to list two different avatars I enter. One for the classic layout and one for horizontal layout.
Just to add the reason why I need to do this. I need to display a different default "No Avatar" in the Horizontal layout, because it requires that "margin-right: 10px;" be added to the css it uses. Done so it matches the other avatars people upload and use, creating a 10 px space between the avatar on the right-side and the rank images.
The margin space cannot be added if the same avatar is also displayed in the Classic Layout. It pushed the avatar 10px over to the left side, it doesn't align center in that classic layout.