News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Echoing a code left to right in columns

Started by Biology Forums, April 06, 2012, 02:00:13 PM

Previous topic - Next topic

Biology Forums

<div style="padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; font-size: 0.9em; line-height: 15px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: #ADADAD; border-right-color: #ADADAD; border-bottom-color: #ADADAD; border-left-color: #ADADAD; border-image: initial; background-color: #ECEDF3; background-attachment: initial; background-origin: initial; background-clip: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 1ex; margin-left: 0px; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; border-radius:5px; color: rgb(0, 0, 0); font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">

<div class="windowbg">

<table><tr><td><a href="'.$scripturl.'?action=profile;u='.$mem['id'].'" class="ssi_membergroup" id="ssi_member_'.$mem['id'].'">'.$mem['name'].'</a> - Administrator</td><td>',empty

($memberContext[$mem['id']]['avatar']['image'])

? '<img src="'.$settings['images_url'].'/noavatar.gif" width="50" height="50" />' : '<img height="50" width="50" src="' . $memberContext[$mem['id']]['avatar']['href'] . '"  alt="'.$mem['name'].'" /></td></tr></table>';

   echo'<ul>';
   
   echo'<li>Get to know <a href="'.$scripturl.'?action=profile;u='.$mem['id'].'" class="ssi_membergroup" id="ssi_member_'.$mem['id'].'">'.$mem['name'].'</a></li>';
   
   if($mem['karmaTotal'] > 0)
   
   echo'
   
   <li>Reputation: <font color="green">'.$mem['karmaTotal'].'</font></li>';
   
   if($mem['karmaTotal'] < 0)
   
   echo'
   
  <li>Rep: <font color="red">'.$mem['karmaTotal'].'</font></li>';
 
  echo'
 
  <li>Posts: <font color="navy">'.$mem['post'].'</font></li>';
     
  echo'<li>Send a <a href="http://biology-forums.com/index.php?action=pm;sa=send;u='.$mem['id'].'">personal message</a></li>
 
<li>Best answer votes recieved: '.$mem['thank_you_post_became'].'</li>
 
 
  <li>Joined the team March 06, 2011</li>';

 
   
   echo'
   
   </ul></div></div>';
}


I have the following code... Is it possible to have the div go left to right (2 columns), then go to the next line and again, go left to right. As opposed to going down one at a time?

Like so:

X X

X X

X X

Instead of:

X

X

X

Antechinus

Have you got it running live somewhere? My brain doesn't work too well this time on a Saturday morning. :)

Biology Forums

Thanks for the reply. I got it to look like this, a 1 row by 4 column mess!

http://biology-forums.com/index.php?action=Tester

I want it to present the data in columns. I know it has something to do with array_chunk, but I don't know how to use it :(

echo' <table width="100%"><tr>';

//Well they want it echo so lets echo...
foreach ($membergroup as $mem) {
loadMemberData($mem['id']);
loadMemberContext($mem['id']);
global $memberContext;
echo '

<td width="50%"><div style="padding: 1ex; font-size: 0.9em; line-height: 15px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: #ADADAD; border-right-color: #ADADAD; border-bottom-color: #ADADAD; border-left-color: #ADADAD; border-image: initial; background-color: #ECEDF3; background-attachment: initial; background-origin: initial; background-clip: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 1ex; margin-left: 0px; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; border-radius:5px; color: rgb(0, 0, 0); font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">

<div class="windowbg">

<table width="100%"><tr><td><a href="'.$scripturl.'?action=profile;u='.$mem['id'].'" class="ssi_membergroup" id="ssi_member_'.$mem['id'].'"><span style="font-weight: bold; text-transform: capitalize;">'.$mem['name'].'</span></a>';

if(!empty($mem['flag']))

echo' <img src="http://biology-forums.com/Sources/shop/flag_images/'.$mem['flag'].'" alt="flag">';



if($groupid == 2 || $groupid == 3)

echo' - Moderator';

if($groupid == 13)

echo' - Trusted Seller';

if($groupid == 1)

echo' - Administrator';

if($groupid == 15)

echo' - Contributor of the Month';

if(!empty($mem['status']))

echo'<br /><small><b>Status:</b> <i>'.$mem['status'].'</i></small>';

echo'</td>

<td width="75" style="padding-left: 1ex; align: center;"><center>',empty

($memberContext[$mem['id']]['avatar']['image'])

? '<img src="'.$settings['images_url'].'/noavatar.gif" width="50" height="50" />' : '<img height="50" width="50" src="' . $memberContext[$mem['id']]['avatar']['href'] . '"  alt="'.$mem['name'].'" /></center></td></tr></table>';

   echo'<ul style="list-style-image:url(http://icons.primail.ch/bullets/c001.gif); padding-top: 0ex; margin-top: 0px;">';
   
   if($mem['karmaTotal'] > 0)
   {
   echo'<li><b>Reputation:</b> <font color="green">'.$mem['karmaTotal'].'</font></li>';
   }
   if($mem['karmaTotal'] < 0)
   {
   echo'<li><b>Reputation:</b> <font color="red">'.$mem['karmaTotal'].'</font></li>';
}
  echo'
 
<li><b>Posts:</b> <font color="navy">'.$mem['post'].'</font></li>
 

 
<li><b>Best answer votes recieved:</b> '.$mem['thank_you_post_became'].'</li>

<li><b>Points Earned:</b> '.$mem['money'].'</li>
   
<li><b>Team member since</b> ' . timeformat($mem['registered']). '</li>

<li><b>Last active</b> ' . timeformat($mem['login']). '</li>

<li>Send a <a href="http://biology-forums.com/index.php?action=pm;sa=send;u='.$mem['id'].'">personal message</a></li>';

echo'
   
   </ul></div></div></td>';
}
echo'</tr></table>';


Antechinus

Ok so do you want two rows of two user blocks per row or what? Not sure what the aim is here.

Biology Forums

Quote from: Antechinus on April 06, 2012, 07:55:21 PM
Ok so do you want two rows of two user blocks per row or what? Not sure what the aim is here.

I want the data to be presented in rows of 2 columns.

Instead of something like this:

1
2
3
4
5
6

I want this:

1 2
3 4
5 6

Antechinus

Ok. Two columns within each user block? Easiest way to do that is with css. Just set each <li> to be 50% width and float :left; That will make them stack in two columns. I'd also add box-sizing so you don't have any worries about padding in the list elements:

<li> {
float: left;
width: 50%;
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
}



Biology Forums

Quote from: Antechinus on April 06, 2012, 09:23:16 PM
Ok. Two columns within each user block? Easiest way to do that is with css. Just set each <li> to be 50% width and float :left; That will make them stack in two columns. I'd also add box-sizing so you don't have any worries about padding in the list elements:

<li> {
float: left;
width: 50%;
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
}


Antechinus, I don't think you're getting what I want...

Generally, code gets displayed one after another like this:

1
2
3
4

I want my data to be displayed in columns. You're right about the listing thing <li>, but how do I incorporate that into the php?

I tried <table>

foreach(data)

{<tr><td>data</td></tr>}

</table>

But this is putting the data in one long row: 1 2 3 4...

I want it to break into new rows after every two:

1 2
3 4.

Antechinus

Yes but exactly which data are you talking about? I asked if you wanted two rows of two user blocks each, but apparently you didn't so the next assumption was that you wanted the list data in two columns within each user block. If that's not what you want either, then I'm stumped. How about mocking up a screenshot of what you do want? Either that or be a lot more specific. :)

Biology Forums

The code I provided is an SSI function that pulls out all the members in group x, for instance. As you can tell from this link (http://biology-forums.com/index.php?action=Tester), there are currently 4 members in group x. The code currently has been designed to give each member their own <td></td>, so in other words, their own column. That's fine, but as you can tell, if you exceed four members, the information will all get squished together because essentially the ssi function is continually spitting out more <td>'s inside the <tr>. I want to program the function so that after every two members it spits out, it starts a new <tr>. I've read around that you have to use the array_chunk() function somehow (http://www.suburban-glory.com/blog?page=64).

I've tried to be as informative as I can, and this is my last attempt at explaining it :(

Antechinus

Ok, I get it now. I'd still do that with css myself. Using tables for layout is very old school and not good practice, so I'd mark it up as a big unordered list. Then you just do the same trick with the <li> bits: set 'em 50% wide and float: left;. Instant two blocks per row for as long as you want to keep stacking them up. :)

I'll write out the markup and basic css for you a bit later. It's a piece of cake once you know how. Hell of a lot easier than templating this bloody software from scratch anyway. :D

Biology Forums

Quote from: Antechinus on April 07, 2012, 02:43:17 AM
Ok, I get it now. I'd still do that with css myself. Using tables for layout is very old school and not good practice, so I'd mark it up as a big unordered list. Then you just do the same trick with the <li> bits: set 'em 50% wide and float: left;. Instant two blocks per row for as long as you want to keep stacking them up. :)

I'll write out the markup and basic css for you a bit later. It's a piece of cake once you know how. Hell of a lot easier than templating this bloody software from scratch anyway. :D

Thanks, I always learned to work with tables, still haven't adjusted to lists and divs. Regardless, could you do it using tables too?

I would like to continue with that theme.

Antechinus

Welllllllllllllllllllllllllllllllllllllllllllllllll......................................................no. :D

Honestly, that code is horrible. Really. There is oodles of inline css, and it is formatted in the most long-winded and ridiculously redundant fashion possible. If you do it another way it will run faster and be much easier to customise. For instance, by changing one value in the css you will be able to change the number of blocks on each row, without going anywhere near the template. It will still call all the standard theme classes, so it should drop straight into your existing theme without causing problems. Trust me on this. I know presentation. :)

I'll give you an example, starting with the main div. At the moment you have this:

<div style="padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; font-size: 0.9em; line-height: 15px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: #ADADAD; border-right-color: #ADADAD; border-bottom-color: #ADADAD; border-left-color: #ADADAD;

You are running over four times as much css as you need to do the job. The following is quite sufficient to deal with the padding and the borders.

padding: 1em; border: 1px solid #ADADAD;

See the difference? Which one would you prefer to deal with if you decide to make changes to your theme? Now do you understand why I want to rewrite it? ;D

By the way, declaring font-size in em and line-height in px is generally not good practice, because IE wont scale any of the font properties that are declared in px. It's better to match the line height units to the font units. This will look the same, or near enough:

font-size: 0.9em; line-height: 1.3em;

Then there's stuff like  this:

border-image: initial;

It doesn't do anything, because its not a valid declaration. "initial" is not a valid value for any of the CSS3 border-image properties. Furthermore, even if you do wish to use border images you would still have to include the vendor-specific prefixes if you want it to work in most browsers, because at the moment only Chrome supports the basic w3 syntax. No current version of IE supports it at all, with or without prefixing.

I'll whip this into shape just for a bit of light entertainment, then you can try it out and see if it does what it says on the tin.


Antechinus

Just been looking at it again this morning, and out of all the inline styles declared for that first div, this is all you need:

.main_div
{
margin: 0 0 1em 0px;
padding: 1em;
font: 0.9em/1.3em "Arial", "Helvetica", sans-serif;
background: #ECEDF3;
color: #000;
border: 1px solid #ADADAD;
border-radius:5px;
orphans: 2;
widows: 2;
}


That's it. Nothing else required, and the last two are only in case someone prints the page anyway.

IchBin™

Liam_michael,

In order to make a column to your specification you need some type of counter. This can be done a few ways, but I'll show one way.

First is to create a counter variable and then to check the value of it. If the value divided by the count of columns you want has a remainder of 0, then you create a new column. Here's a quick code mock-up since it's kind of hard to explain.

$number_of_columns = 2;
$counter = 0;

echo '
<table>';

foreach ($membergroup as $mem) {
// loop through your $mem stuff and create your rows
echo '
<tr>
<td> Do stuff for first column</td>
<td> Do stuff for second column</td>';
if ($counter % $number_of_rows == 0) {
// if the counter divided by number of rows has a remainder of 0 end current row and add another row.
echo '
</tr>
<tr>';
}
// Add 1 to the counter
$counter++;
}
IchBin™        TinyPortal

Biology Forums

Quote from: IchBin™ on April 07, 2012, 10:44:52 PM
Liam_michael,

In order to make a column to your specification you need some type of counter. This can be done a few ways, but I'll show one way.

First is to create a counter variable and then to check the value of it. If the value divided by the count of columns you want has a remainder of 0, then you create a new column. Here's a quick code mock-up since it's kind of hard to explain.

$number_of_columns = 2;
$counter = 0;

echo '
<table>';

foreach ($membergroup as $mem) {
// loop through your $mem stuff and create your rows
echo '
<tr>
<td> Do stuff for first column</td>
<td> Do stuff for second column</td>';
if ($counter % $number_of_rows == 0) {
// if the counter divided by number of rows has a remainder of 0 end current row and add another row.
echo '
</tr>
<tr>';
}
// Add 1 to the counter
$counter++;
}


Thanks IchBin™, you actually understand what it is I'm looking to accomplish!

Could you set it up in terms of this code?

function ssi_membergroupadmins($groupid = 1, $additional = 0, $sort = 1, $sortorder = 1, $output_method = 'echo')
{
global $db_prefix, $user_info, $scripturl, $modSettings, $txt, $sc;
//-- $mgroup = Group Number
//-- $Additional = Search Additional Groups as well
//-- $sort = How to sort the names. ID Number(2) or realname(1 default).
//-- $sortorder = Sort ASC or DESC

//Lets get some checks done for the sake of the script not returning errors
//if the groupids are array we need to make them valid.
if(is_array($groupid))
$groupid = array_map('intval',$groupid);

//Well the groupid is a single id.. lets make it valid..
if(!is_array($groupid))
$groupid = (int) $groupid;

//Either its off or its on.. Should also stop use of array..
if(($additional !=0 && $additional !=1) || ($sort !=2 && $sort !=1) || ($sortorder !=2 && $sortorder !=1))
fatal_error('Invalid Input for this ssi_function');

//We shouldn't be getting Group 0. Fix it by Showing Admin Group..
if($groupid == 0)
$groupid = 1;

//Set our output to something its better than nothing.
$membergroup = array();

//Find out if our groups we are looking at is in an array or not..
if(is_array($groupid))
{
//Array has multiple groups so if we want to search additional as well we have to loop it.
if(isset($additional) && $additional != 0)
{
//lets just clear additional instead of a new variable.
$additional = '';
foreach($groupid as $add)
$additional .= '
OR FIND_IN_SET('.$add.', additionalGroups)';
}
$request = db_query("
SELECT ID_MEMBER, realname, ID_GROUP, avatar, karmaBad, karmaGood, emailAddress, posts
FROM {$db_prefix}members
WHERE ID_GROUP IN (" . implode(', ',$groupid) . ")".$additional."
ORDER BY '".($sort == 2 ? 'ID_MEMBER' : 'realname')."' ".($sortorder == 2 ? 'DESC' : 'ASC')."", __FILE__, __LINE__);
}
else
$request = db_query("
SELECT ID_MEMBER, realname, ID_GROUP, avatar, karmaBad, karmaGood,  emailAddress, posts, thank_you_post_became, thank_you_post_made, money, shop_Flag, personalText, dateRegistered, lastLogin
FROM {$db_prefix}members
WHERE ID_GROUP = " . $groupid . ($additional == 1 ? "
OR FIND_IN_SET(" . $groupid . ", additionalGroups)" : "")."
ORDER BY '".($sort == 2 ? 'ID_MEMBER' : 'realname')."' ".($sortorder == 2 ? 'DESC' : 'ASC')."", __FILE__, __LINE__);

//We got the query. Now lets get it into a nice little array..
while ($row = mysql_fetch_assoc($request))
$membergroup[] = array(
'id' => $row['ID_MEMBER'],
'name' => $row['realname'],
'group' => $row['ID_GROUP'],
'post' => $row['posts'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'avatar' => array(
             'image' => stristr($row['avatar'], 'http://') ? 'src="' . $row['avatar'] . '" alt="Profile Display Picture" border="0" />' : 'src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="Profile Display Picture" border="0" />',
          ),
  'karmaGood' => $row['karmaGood'],
'karmaBad' => $row['karmaBad'],
'karmaTotal' => $row['karmaGood'] - $row['karmaBad'],
 
'mail' => $row['emailAddress'],
'login' => $row['lastLogin'],
'registered' => $row['dateRegistered'],
'status' => $row['personalText'],
'flag' => $row['shop_Flag'],
'thank_you_post_became' => $row['thank_you_post_became'],
'money' => $row['money'],
'thank_you_post_made' => $row['thank_you_post_made']
);
mysql_free_result($request);

//If they dont want to echo.. So lets give it to them..
if ($output_method != 'echo')
return $membergroup;

echo' <table width="100%"><tr>';

//Well they want it echo so lets echo...
foreach ($membergroup as $mem) {
loadMemberData($mem['id']);
loadMemberContext($mem['id']);
global $memberContext;
echo '

<td width="50%"><div style="padding: 1ex; font-size: 0.9em; line-height: 15px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: #ADADAD; border-right-color: #ADADAD; border-bottom-color: #ADADAD; border-left-color: #ADADAD; border-image: initial; background-color: #ECEDF3; background-attachment: initial; background-origin: initial; background-clip: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 1ex; margin-left: 0px; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; border-radius:5px; color: rgb(0, 0, 0); font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">

<div class="windowbg">

<table width="100%"><tr><td><a href="'.$scripturl.'?action=profile;u='.$mem['id'].'" class="ssi_membergroup" id="ssi_member_'.$mem['id'].'"><span style="font-weight: bold; text-transform: capitalize;">'.$mem['name'].'</span></a>';

if(!empty($mem['flag']))

echo' <img src="http://biology-forums.com/Sources/shop/flag_images/'.$mem['flag'].'" alt="flag">';



if($groupid == 2 || $groupid == 3)

echo' - Moderator';

if($groupid == 13)

echo' - Trusted Seller';

if($groupid == 1)

echo' - Administrator';

if($groupid == 15)

echo' - Contributor of the Month';

if(!empty($mem['status']))

echo'<br /><small><b>Status:</b> <i>'.$mem['status'].'</i></small>';

echo'</td>

<td width="75" style="padding-left: 1ex; align: center;"><center>',empty

($memberContext[$mem['id']]['avatar']['image'])

? '<img src="'.$settings['images_url'].'/noavatar.gif" width="50" height="50" />' : '<img height="50" width="50" src="' . $memberContext[$mem['id']]['avatar']['href'] . '"  alt="'.$mem['name'].'" /></center></td></tr></table>';

   echo'<ul style="list-style-image:url(http://icons.primail.ch/bullets/c001.gif); padding-top: 0ex; margin-top: 0px;">';
   
   if($mem['karmaTotal'] > 0)
   {
   echo'<li><b>Reputation:</b> <font color="green">'.$mem['karmaTotal'].'</font></li>';
   }
   if($mem['karmaTotal'] < 0)
   {
   echo'<li><b>Reputation:</b> <font color="red">'.$mem['karmaTotal'].'</font></li>';
}
  echo'
 
<li><b>Posts:</b> <font color="navy">'.$mem['post'].'</font></li>
 

 
<li><b>Best answer votes recieved:</b> '.$mem['thank_you_post_became'].'</li>

<li><b>Points Earned:</b> '.$mem['money'].'</li>
   
<li><b>Team member since</b> ' . timeformat($mem['registered']). '</li>

<li><b>Last active</b> ' . timeformat($mem['login']). '</li>

<li>Send a <a href="http://biology-forums.com/index.php?action=pm;sa=send;u='.$mem['id'].'">personal message</a></li>';

echo'
   
   </ul></div></div></td>';
}
echo'</tr></table>';
}

Antechinus

Hey, try this. :D Srsly.

The PHP:

global $MemberData, $memberContext, $scripturl, $membergroup, $mem, $groupid, $context;

echo'
<ul id="member_blocks_wrapper">';

//Well they want it echo so lets echo...
foreach ($membergroup as $mem)
{
loadMemberData($mem['id']);
loadMemberContext($mem['id']);
echo '
<li class="member_containers">
<ul class="windowbg member_blocks">
<li class="member_name">
<a href="'.$scripturl.'?action=profile;u='.$mem['id'].'" class="ssi_membergroup" id="ssi_member_'.$mem['id'].'">
'.$mem['name'].'
</a>';
if(!empty($mem['flag']))
echo'
<img src="http://biology-forums.com/Sources/shop/flag_images/'.$mem['flag'].'" alt="flag">';
if($groupid == 1)
echo'
- Administrator';
if($groupid == 2 || $groupid == 3)
echo'
- Moderator';
if($groupid == 13)
echo' - Trusted Seller';
if($groupid == 15)
echo'
- Contributor of the Month';
if(!empty($mem['status']))
echo'
<div>Status:&nbsp;<span>'.$mem['status'].'</span></div>';
echo'
</li>
<li class="member_avatar">
', ($memberContext[$mem['id']]['avatar']['image']) ? '<img src="'.$settings['images_url'].'/noavatar.gif" width="50" height="50" />' : '<img height="50" width="50" src="' . $memberContext[$mem['id']]['avatar']['href'] . '"  alt="'.$mem['name'].'" />', '
</li>
<li class="member_rep">
Reputation: <span class="', ($mem['karmaTotal'] > 0) ? 'karma_pos' : 'karma_neg', '">'.$mem['karmaTotal'].'</span>
</li>
<li class="member_posts">
Posts: <span>'.$mem['post'].'</span>
</li>
<li class="member_votes">
Best answer votes received: <span>'.$mem['thank_you_post_became'].'</span>
</li>
<li class="member_points">
Points Earned: <span>'.$mem['money'].'</span>
</li>
<li class="member_since">
Team member since: <span>' . timeformat($mem['registered']). '<span>
</li>
<li class="member_active">
Last active: <span>' . timeformat($mem['login']). '</span>
</li>';
if($context['allow_pm'])
echo '
<li class="member_pm">
Send a <a href="'.$scripturl.'?action=pm;sa=send;u='.$mem['id'].'">personal message</a>
</li>';
echo '
</ul>
</li>';
}

echo'
</ul>';


The CSS:

/* This should work. Better than tables. */
/* Seriously, you should try it. :D */

#member_blocks_wrapper {
margin: 5px;
/* This will make the ul wrap floated content, but should not cause scroll bars. */
overflow: auto;
}
#member_blocks_wrapper li.member_containers {
float: left;
/* If you decide you want three blocks per row, change the next value to 33.3% */
/* If you decide you want four blocks per row, change the next value to 25% */
width: 50%;
/* The next three are necessary to prevent content paddings being added to overall width. */
/* IE8+ and Opera accept the basic W3 syntax. Firefox and Safari/Chrome still require prefixes. */
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
ul.member_blocks {
margin: 5px;
padding: 1em;
font: 0.9em/1.3em "Arial", "Helvetica", sans-serif;
background: #ECEDF3;
color: #000;
border: 1px solid #ADADAD;
border-radius:5px;
orphans: 2;
widows: 2;
}
li.member_name {
float: left;
}
li.member_name a {
font-weight: bold;
text-transform: capitalize;
}
li.member_name div {
font-weight: bold;
font-size: 0.9em;
}
li.member_name div span {
font-weight: normal;
font-style:italic;
}
li.member_rep, li.member_posts, li.member_votes,
li.member_points, li.member_since, li.member_active {
font-weight: bold;
}
li.member_rep span, li.member_posts span, li.member_votes span,
li.member_points span, li.member_since span, li.member_active span {
font-weight: normal;
}
li.member_avatar {
float: right;
width: 75px;
text-align: center;
padding: 0;
}
.karma_pos {
color: green;
}
.karma_neg {
color: red;
}
li.posts span {
color: navy;
}

IchBin™

#17
Your code is pretty ugly. But the more you do it, the more you'll become anal about it as you'll find most of us are. :D

If ants doesn't work ( haven't looked at his) give this a shot.

<?php

function ssi_membergroupadmins($groupid 1$additional 0$sort 1$sortorder 1$output_method 'echo')
{
global $db_prefix$user_info$scripturl$modSettings$txt$sc;
//-- $mgroup = Group Number
//-- $Additional = Search Additional Groups as well
//-- $sort = How to sort the names. ID Number(2) or realname(1 default).
//-- $sortorder = Sort ASC or DESC

//Lets get some checks done for the sake of the script not returning errors
//if the groupids are array we need to make them valid.
if(is_array($groupid))
$groupid array_map('intval',$groupid);

//Well the groupid is a single id.. lets make it valid..
if(!is_array($groupid))
$groupid = (int) $groupid;

//Either its off or its on.. Should also stop use of array..
if(($additional !=&& $additional !=1) || ($sort !=&& $sort !=1) || ($sortorder !=&& $sortorder !=1))
fatal_error('Invalid Input for this ssi_function');

//We shouldn't be getting Group 0. Fix it by Showing Admin Group..
if($groupid == 0)
$groupid 1;

//Set our output to something its better than nothing.
$membergroup = array();

//Find out if our groups we are looking at is in an array or not..
if(is_array($groupid))
{
//Array has multiple groups so if we want to search additional as well we have to loop it.
if(isset($additional) && $additional != 0)
{
//lets just clear additional instead of a new variable.
$additional '';
foreach($groupid as $add)
$additional .= '
OR FIND_IN_SET('
.$add.', additionalGroups)';
}
$request db_query("
SELECT ID_MEMBER, realname, ID_GROUP, avatar, karmaBad, karmaGood, emailAddress, posts
FROM 
{$db_prefix}members
WHERE ID_GROUP IN (" 
implode(', ',$groupid) . ")".$additional."
ORDER BY '"
.($sort == 'ID_MEMBER' 'realname')."' ".($sortorder == 'DESC' 'ASC').""__FILE____LINE__);
}
else
$request db_query("
SELECT ID_MEMBER, realname, ID_GROUP, avatar, karmaBad, karmaGood,  emailAddress, posts, thank_you_post_became, thank_you_post_made, money, shop_Flag, personalText, dateRegistered, lastLogin
FROM 
{$db_prefix}members
WHERE ID_GROUP = " 
$groupid . ($additional == "
OR FIND_IN_SET(" 
$groupid ", additionalGroups)" "")."
ORDER BY '"
.($sort == 'ID_MEMBER' 'realname')."' ".($sortorder == 'DESC' 'ASC').""__FILE____LINE_);

//We got the query. Now lets get it into a nice little array..
while ($row mysql_fetch_assoc($request))
$membergroup[] = array(
'id' => $row['ID_MEMBER'],
'name' => $row['realname'],
'group' => $row['ID_GROUP'],
'post' => $row['posts'],
'href' => $scripturl '?action=profile;u=' $row['ID_MEMBER'],
'avatar' => array(
             
'image' => stristr($row['avatar'], 'http://') ? 'src="' $row['avatar'] . '" alt="Profile Display Picture" border="0" />' 'src="' $modSettings['avatar_url'] . '/' htmlspecialchars($row['avatar']) . '" alt="Profile Display Picture" border="0" />',
          ),
  'karmaGood' => $row['karmaGood'],
'karmaBad' => $row['karmaBad'],
'karmaTotal' => $row['karmaGood'] - $row['karmaBad'],
'mail' => $row['emailAddress'],
'login' => $row['lastLogin'],
'registered' => $row['dateRegistered'],
'status' => $row['personalText'],
'flag' => $row['shop_Flag'],
'thank_you_post_became' => $row['thank_you_post_became'],
'money' => $row['money'],
'thank_you_post_made' => $row['thank_you_post_made']
);
mysql_free_result($request);

//If they dont want to echo.. So lets give it to them..
if ($output_method != 'echo')
return $membergroup;

echo'
<table width="100%">
<tr>'
;

$counter = -1;
$columns 2;
//Well they want it echo so lets echo...
foreach ($membergroup as $mem) {
loadMemberData($mem['id']);
loadMemberContext($mem['id']);
global $memberContext
echo '
<td width="50%">
<div style="padding: 1ex; font-size: 0.9em; line-height: 15px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: #ADADAD; border-right-color: #ADADAD; border-bottom-color: #ADADAD; border-left-color: #ADADAD; border-image: initial; background-color: #ECEDF3; background-attachment: initial; background-origin: initial; background-clip: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 1ex; margin-left: 0px; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; border-radius:5px; color: rgb(0, 0, 0); font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<div class="windowbg">
<table width="100%">
<tr>
<td>
<a href="'
.$scripturl.'?action=profile;u='.$mem['id'].'" class="ssi_membergroup" id="ssi_member_'.$mem['id'].'"><span style="font-weight: bold; text-transform: capitalize;">'.$mem['name'].'</span></a>';

if(!empty($mem['flag']))
echo'
<img src="http://biology-forums.com/Sources/shop/flag_images/'
.$mem['flag'].'" alt="flag">';

if($groupid == || $groupid == 3)
echo' - Moderator';

if($groupid == 13)
echo' - Trusted Seller';

if($groupid == 1)
echo' - Administrator';

if($groupid == 15)
echo' - Contributor of the Month';

if(!empty($mem['status']))
echo'
<br /><small><b>Status:</b> <i>'
.$mem['status'].'</i></small>';

echo'
</td>
<td width="75" style="padding-left: 1ex; align: center;">
<center>'
,empty($memberContext[$mem['id']]['avatar']['image']) ? 
'<img src="'.$settings['images_url'].'/noavatar.gif" width="50" height="50" />' :
'<img height="50" width="50" src="' $memberContext[$mem['id']]['avatar']['href'] . '"  alt="'.$mem['name'].'" />';
echo '
</center>
</td>
</tr>
</table>'
;
 
   echo'
<ul style="list-style-image:url(http://icons.primail.ch/bullets/c001.gif); padding-top: 0ex; margin-top: 0px;">'
;
   
if($mem['karmaTotal'] > 0)
echo'
<li><b>Reputation:</b> <font color="green">'
.$mem['karmaTotal'].'</font></li>';

if($mem['karmaTotal'] < 0)
echo'
<li><b>Reputation:</b> <font color="red">'
.$mem['karmaTotal'].'</font></li>';

echo'
<li><b>Posts:</b> <font color="navy">'
.$mem['post'].'</font></li>
<li><b>Best answer votes recieved:</b> '
.$mem['thank_you_post_became'].'</li>
<li><b>Points Earned:</b> '
.$mem['money'].'</li>
<li><b>Team member since</b> ' 
timeformat($mem['registered']). '</li>
<li><b>Last active</b> ' 
timeformat($mem['login']). '</li>
<li>Send a <a href="http://biology-forums.com/index.php?action=pm;sa=send;u='
.$mem['id'].'">personal message</a></li>';

echo'
</ul>

</div>
</div>
</td>'
;
if ($counter $columns == 0)

echo '
</tr>
<tr>'
;


$counter++;
}

echo'
</tr>
</table>'
;
}
IchBin™        TinyPortal

Antechinus

Quote from: IchBin™ on April 08, 2012, 05:07:33 PM
Your code is pretty ugly. But the more you do it, the more you'll become anal about it as you'll find most of us are. :D

If ants doesn't work......................

:P :P :D

Norv

Quote from: IchBin™ on April 08, 2012, 05:07:33 PM
Your code is pretty ugly. But the more you do it, the more you'll become anal about it as you'll find most of us are. :D

If ants doesn't work

* Norv rolls on the chair laughing.



(sorry for interjecting, couldn't help it lol. Nice job there. :D)
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

Antechinus

Well, tbh it may need a little tweaking on the styling since I didn't test it live, on account of the PHP containing a lot of custom stuff that would only throw errors on my local site. However, it should be pretty close.

Biology Forums

Quote from: IchBin™ on April 08, 2012, 05:07:33 PM
Your code is pretty ugly. But the more you do it, the more you'll become anal about it as you'll find most of us are. :D

If ants doesn't work ( haven't looked at his) give this a shot.

<?php
function ssi_membergroupadmins($groupid 1$additional 0$sort 1$sortorder 1$output_method 'echo')
{
global $db_prefix$user_info$scripturl$modSettings$txt$sc;
//-- $mgroup = Group Number
//-- $Additional = Search Additional Groups as well
//-- $sort = How to sort the names. ID Number(2) or realname(1 default).
//-- $sortorder = Sort ASC or DESC

//Lets get some checks done for the sake of the script not returning errors
//if the groupids are array we need to make them valid.
if(is_array($groupid))
$groupid array_map('intval',$groupid);

//Well the groupid is a single id.. lets make it valid..
if(!is_array($groupid))
$groupid = (int) $groupid;

//Either its off or its on.. Should also stop use of array..
if(($additional !=&& $additional !=1) || ($sort !=&& $sort !=1) || ($sortorder !=&& $sortorder !=1))
fatal_error('Invalid Input for this ssi_function');

//We shouldn't be getting Group 0. Fix it by Showing Admin Group..
if($groupid == 0)
$groupid 1;

//Set our output to something its better than nothing.
$membergroup = array();

//Find out if our groups we are looking at is in an array or not..
if(is_array($groupid))
{
//Array has multiple groups so if we want to search additional as well we have to loop it.
if(isset($additional) && $additional != 0)
{
//lets just clear additional instead of a new variable.
$additional '';
foreach($groupid as $add)
$additional .= '
OR FIND_IN_SET('
.$add.', additionalGroups)';
}
$request db_query("
SELECT ID_MEMBER, realname, ID_GROUP, avatar, karmaBad, karmaGood, emailAddress, posts
FROM 
{$db_prefix}members
WHERE ID_GROUP IN (" 
implode(', ',$groupid) . ")".$additional."
ORDER BY '"
.($sort == 'ID_MEMBER' 'realname')."' ".($sortorder == 'DESC' 'ASC').""__FILE____LINE__);
}
else
$request db_query("
SELECT ID_MEMBER, realname, ID_GROUP, avatar, karmaBad, karmaGood,  emailAddress, posts, thank_you_post_became, thank_you_post_made, money, shop_Flag, personalText, dateRegistered, lastLogin
FROM 
{$db_prefix}members
WHERE ID_GROUP = " 
$groupid . ($additional == "
OR FIND_IN_SET(" 
$groupid ", additionalGroups)" "")."
ORDER BY '"
.($sort == 'ID_MEMBER' 'realname')."' ".($sortorder == 'DESC' 'ASC').""__FILE____LINE_);

//We got the query. Now lets get it into a nice little array..
while ($row mysql_fetch_assoc($request))
$membergroup[] = array(
'id' => $row['ID_MEMBER'],
'name' => $row['realname'],
'group' => $row['ID_GROUP'],
'post' => $row['posts'],
'href' => $scripturl '?action=profile;u=' $row['ID_MEMBER'],
'avatar' => array(
             
'image' => stristr($row['avatar'], 'http://') ? 'src="' $row['avatar'] . '" alt="Profile Display Picture" border="0" />' 'src="' $modSettings['avatar_url'] . '/' htmlspecialchars($row['avatar']) . '" alt="Profile Display Picture" border="0" />',
          ),
  'karmaGood' => $row['karmaGood'],
'karmaBad' => $row['karmaBad'],
'karmaTotal' => $row['karmaGood'] - $row['karmaBad'],
'mail' => $row['emailAddress'],
'login' => $row['lastLogin'],
'registered' => $row['dateRegistered'],
'status' => $row['personalText'],
'flag' => $row['shop_Flag'],
'thank_you_post_became' => $row['thank_you_post_became'],
'money' => $row['money'],
'thank_you_post_made' => $row['thank_you_post_made']
);
mysql_free_result($request);

//If they dont want to echo.. So lets give it to them..
if ($output_method != 'echo')
return $membergroup;

echo'
<table width="100%">
<tr>'
;

$counter 0;
$columns 2;
//Well they want it echo so lets echo...
foreach ($membergroup as $mem) {
loadMemberData($mem['id']);
loadMemberContext($mem['id']);
global $memberContext
echo '
<td width="50%">
<div style="padding: 1ex; font-size: 0.9em; line-height: 15px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: #ADADAD; border-right-color: #ADADAD; border-bottom-color: #ADADAD; border-left-color: #ADADAD; border-image: initial; background-color: #ECEDF3; background-attachment: initial; background-origin: initial; background-clip: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 1ex; margin-left: 0px; border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; border-radius:5px; color: rgb(0, 0, 0); font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-position: initial initial; background-repeat: initial initial;">
<div class="windowbg">
<table width="100%">
<tr>
<td>
<a href="'
.$scripturl.'?action=profile;u='.$mem['id'].'" class="ssi_membergroup" id="ssi_member_'.$mem['id'].'"><span style="font-weight: bold; text-transform: capitalize;">'.$mem['name'].'</span></a>';

if(!empty($mem['flag']))
echo'
<img src="http://biology-forums.com/Sources/shop/flag_images/'
.$mem['flag'].'" alt="flag">';

if($groupid == || $groupid == 3)
echo' - Moderator';

if($groupid == 13)
echo' - Trusted Seller';

if($groupid == 1)
echo' - Administrator';

if($groupid == 15)
echo' - Contributor of the Month';

if(!empty($mem['status']))
echo'
<br /><small><b>Status:</b> <i>'
.$mem['status'].'</i></small>';

echo'
</td>
<td width="75" style="padding-left: 1ex; align: center;">
<center>'
,empty($memberContext[$mem['id']]['avatar']['image']) ? 
'<img src="'.$settings['images_url'].'/noavatar.gif" width="50" height="50" />' :
'<img height="50" width="50" src="' $memberContext[$mem['id']]['avatar']['href'] . '"  alt="'.$mem['name'].'" />';
echo '
</center>
</td>
</tr>
</table>'
;
 
   echo'
<ul style="list-style-image:url(http://icons.primail.ch/bullets/c001.gif); padding-top: 0ex; margin-top: 0px;">'
;
   
if($mem['karmaTotal'] > 0)
echo'
<li><b>Reputation:</b> <font color="green">'
.$mem['karmaTotal'].'</font></li>';

if($mem['karmaTotal'] < 0)
echo'
<li><b>Reputation:</b> <font color="red">'
.$mem['karmaTotal'].'</font></li>';

echo'
<li><b>Posts:</b> <font color="navy">'
.$mem['post'].'</font></li>
<li><b>Best answer votes recieved:</b> '
.$mem['thank_you_post_became'].'</li>
<li><b>Points Earned:</b> '
.$mem['money'].'</li>
<li><b>Team member since</b> ' 
timeformat($mem['registered']). '</li>
<li><b>Last active</b> ' 
timeformat($mem['login']). '</li>
<li>Send a <a href="http://biology-forums.com/index.php?action=pm;sa=send;u='
.$mem['id'].'">personal message</a></li>';

echo'
</ul>
</div>
</div>
</td>'
;
if ($columns $counter == 0)
echo '
</tr>
<tr>'
;

$counter++;
 }

echo'
</tr>
</table>'
;
}


Thanks for the honesty, IchBin. Problem though, it still isn't inputting the members in columns of 2 :( It is still like this:

X
X
X
X
X

Instead of

XX
XX
XX

http://biology-forums.com/index.php?action=Tester

This is what your code produces.

Marcus Forsberg

Did you try Ant's code at all? It looks good to me and, as he's been trying to say, it's a heck of a lot better to use CSS (and external CSS, not inline!) than tables.

IchBin™

haha, I bet at first Ant you were probably like "wtf" until I specified I wasn't talking about your code. lol

Updated my code after I actually tested it. :D
IchBin™        TinyPortal

Biology Forums

Quote from: Marcus Forsberg on April 09, 2012, 04:26:33 AM
Did you try Ant's code at all? It looks good to me and, as he's been trying to say, it's a heck of a lot better to use CSS (and external CSS, not inline!) than tables.

Yes, I ended up trying it and it looks like this:

http://biology-forums.com/index.php?action=staff

It's perfect, but I wish the blocks where a bit wider for each member.

Still waiting on IchBin™ to see if his table version will work.

IchBin™

Quote from: Liam_michael on April 09, 2012, 12:19:59 PM

Still waiting on IchBin™ to see if his table version will work.

As I just said in my post before yours, I updated my code. Check the post where I posted the code and you'll see a couple of changes. :)
IchBin™        TinyPortal

Biology Forums

Quote from: IchBin™ on April 09, 2012, 01:29:08 PM
Quote from: Liam_michael on April 09, 2012, 12:19:59 PM

Still waiting on IchBin™ to see if his table version will work.

As I just said in my post before yours, I updated my code. Check the post where I posted the code and you'll see a couple of changes. :)

Looks great, thanks to both IchBin and Antechinus

@IchBin, when there is only 1 person in the membergroup... See http://biology-forums.com/index.php?action=staff (All the way at the bottom), it spreads the block all the way 100%.

How do I change it so that the block for that one member is the same as everyone else?

Is that possible?

IchBin™

You'll have to change the html and stuff to not display it 100%. I think you have some tables in their set to display 100%.
IchBin™        TinyPortal

Biology Forums

Quote from: IchBin™ on April 09, 2012, 02:15:37 PM
You'll have to change the html and stuff to not display it 100%. I think you have some tables in their set to display 100%.

True,

I tried this:

echo'
<table

', $membergroup == '1' ? 'width="50%"' : 'width="100%"','><tr>';


But it didn't work.

IchBin™

IchBin™        TinyPortal

Biology Forums

Quote from: IchBin™ on April 09, 2012, 02:58:20 PM
I think you mean $mem['id'] == '1'

No, no... That's called after words:

echo'
<table ', $membergroup == '1' ? 'width="50%"' : 'width="100%"','>
<tr>';

$counter = -1;
$columns = 2;
//Well they want it echo so lets echo...
foreach ($membergroup as $mem) {
loadMemberData($mem['id']);
loadMemberContext($mem['id']);
global $memberContext;
echo '
<td width="50%">
.
.
.


With my attempt, I'm trying to tell the computer that if there is only 1 person in the membergroup, make the parent table 50% instead of 100%.

Antechinus

Question: if mine was perfect, why on earth would you want to use a table version with inline css?

Also, my code would automatically make all blocks the same width on all rows, regardless of how many blocks you put on each row.

Biology Forums

Quote from: Antechinus on April 09, 2012, 05:18:23 PM
Question: if mine was perfect, why on earth would you want to use a table version with inline css?

Also, my code would automatically make all blocks the same width on all rows, regardless of how many blocks you put on each row.

Good question. Here's why... if, for instance, one member's block had more information than the next member in the membergoup (so essentially increasing the height of a single block), it would not automatically adjust the next person's block. As a result, the next member would be forced to show up in a new row. Hard to explain on paper, but if I can't get IchBin™ to fix this little problem, I will go back to your code, since it's only a small sacrifice.


Antechinus

Ah. Well that wouldn't be hard to fix if I could see it running live. As I said, due to the amount of custom code you were running I didn't actually test anything live, because it would just have thrown a lot of errors on my test site.

Biology Forums

Quote from: Antechinus on April 09, 2012, 05:50:15 PM
Ah. Well that wouldn't be hard to fix if I could see it running live. As I said, due to the amount of custom code you were running I didn't actually test anything live, because it would just have thrown a lot of errors on my test site.

Oh true, here's a live example of your code (http://biology-forums.com/index.php?action=staff)

Check out Biolove and see what happens. :'(

Here's your code in full effect :D

// Show From all from a member group. Great for Rosters.
function ssi_membergroupadmins($groupid = 1, $additional = 0, $sort = 1, $sortorder = 1, $output_method = 'echo')
{
global $db_prefix, $user_info, $scripturl, $modSettings, $txt, $sc;
//-- $mgroup = Group Number
//-- $Additional = Search Additional Groups as well
//-- $sort = How to sort the names. ID Number(2) or realname(1 default).
//-- $sortorder = Sort ASC or DESC

//Lets get some checks done for the sake of the script not returning errors
//if the groupids are array we need to make them valid.
if(is_array($groupid))
$groupid = array_map('intval',$groupid);

//Well the groupid is a single id.. lets make it valid..
if(!is_array($groupid))
$groupid = (int) $groupid;

//Either its off or its on.. Should also stop use of array..
if(($additional !=0 && $additional !=1) || ($sort !=2 && $sort !=1) || ($sortorder !=2 && $sortorder !=1))
fatal_error('Invalid Input for this ssi_function');

//We shouldn't be getting Group 0. Fix it by Showing Admin Group..
if($groupid == 0)
$groupid = 1;

//Set our output to something its better than nothing.
$membergroup = array();

//Find out if our groups we are looking at is in an array or not..
if(is_array($groupid))
{
//Array has multiple groups so if we want to search additional as well we have to loop it.
if(isset($additional) && $additional != 0)
{
//lets just clear additional instead of a new variable.
$additional = '';
foreach($groupid as $add)
$additional .= '
OR FIND_IN_SET('.$add.', additionalGroups)';
}
$request = db_query("
SELECT ID_MEMBER, realname, ID_GROUP, avatar, karmaBad, karmaGood,  emailAddress, posts, thank_you_post_became, thank_you_post_made, money, shop_Flag, personalText, dateRegistered, lastLogin
FROM {$db_prefix}members
WHERE ID_GROUP IN (" . implode(', ',$groupid) . ")".$additional."
ORDER BY '".($sort == 2 ? 'ID_MEMBER' : 'realname')."' ".($sortorder == 2 ? 'DESC' : 'ASC')."", __FILE__, __LINE__);
}
else
$request = db_query("
SELECT ID_MEMBER, realname, ID_GROUP, avatar, karmaBad, karmaGood,  emailAddress, posts, thank_you_post_became, thank_you_post_made, money, shop_Flag, personalText, dateRegistered, lastLogin
FROM {$db_prefix}members
WHERE ID_GROUP = " . $groupid . ($additional == 1 ? "
OR FIND_IN_SET(" . $groupid . ", additionalGroups)" : "")."
ORDER BY '".($sort == 2 ? 'ID_MEMBER' : 'realname')."' ".($sortorder == 2 ? 'DESC' : 'ASC')."", __FILE__, __LINE__);

//We got the query. Now lets get it into a nice little array..
while ($row = mysql_fetch_assoc($request))
$membergroup[] = array(
'id' => $row['ID_MEMBER'],
'name' => $row['realname'],
'group' => $row['ID_GROUP'],
'post' => $row['posts'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'avatar' => array(
             'image' => stristr($row['avatar'], 'http://') ? 'src="' . $row['avatar'] . '" alt="Profile Display Picture" border="0" />' : 'src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="Profile Display Picture" border="0" />',
          ),
  'karmaGood' => $row['karmaGood'],
'karmaBad' => $row['karmaBad'],
'karmaTotal' => $row['karmaGood'] - $row['karmaBad'],
 
'mail' => $row['emailAddress'],
'login' => $row['lastLogin'],
'registered' => $row['dateRegistered'],
'status' => $row['personalText'],
'flag' => $row['shop_Flag'],
'thank_you_post_became' => $row['thank_you_post_became'],
'money' => $row['money'],
'thank_you_post_made' => $row['thank_you_post_made']
);
mysql_free_result($request);

//If they dont want to echo.. So lets give it to them..
if ($output_method != 'echo')
return $membergroup;
global $settings;
echo'

<style>/* This should work. Better than tables. */
/* Seriously, you should try it. :D */

#member_blocks_wrapper {
list-style-type: none;
margin: 5px;
/* This will make the ul wrap floated content, but should not cause scroll bars. */
overflow: auto;
}
#member_blocks_wrapper li.member_containers {
float: left;

/* If you decide you want three blocks per row, change the next value to 33.3% */
/* If you decide you want four blocks per row, change the next value to 25% */
width: 50%;
/* The next three are necessary to prevent content paddings being added to overall width. */
/* IE8+ and Opera accept the basic W3 syntax. Firefox and Safari/Chrome still require prefixes. */
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
ul.member_blocks {
margin: 5px;
list-style-type: none;
padding: 1em;
font: 0.9em/1.3em "Arial", "Helvetica", sans-serif;
background: #ECEDF3;
color: #000;
border: 1px solid #ADADAD;
border-radius:5px;
orphans: 2;
widows: 2;
}
li.member_name {
float: left;
}
li.member_name a {
font-weight: bold;
text-transform: capitalize;
}
li.member_name div {
font-weight: bold;
font-size: 0.9em;
}
li.member_name div span {
font-weight: normal;
font-style:italic;
}
li.member_rep, li.member_posts, li.member_votes,
li.member_points, li.member_since, li.member_active {
font-weight: bold;
}
li.member_rep span, li.member_posts span, li.member_votes span,
li.member_points span, li.member_since span, li.member_active span {
font-weight: normal;
}
li.member_avatar {
float: right;
width: 75px;
text-align: center;
padding: 0;
}
.karma_pos {
color: green;
}
.karma_neg {
color: red;
}
li.posts span {
color: navy;
}</style>

<ul id="member_blocks_wrapper">';

//Well they want it echo so lets echo...
foreach ($membergroup as $mem)
{
loadMemberData($mem['id']);
loadMemberContext($mem['id']);
global $memberContext;
echo '
<li class="member_containers">
<ul class="windowbg member_blocks">
<li class="member_name">
<a href="'.$scripturl.'?action=profile;u='.$mem['id'].'" class="ssi_membergroup" id="ssi_member_'.$mem['id'].'">
'.$mem['name'].'
</a>';
if(!empty($mem['flag']))
echo'
<img src="http://biology-forums.com/Sources/shop/flag_images/'.$mem['flag'].'" alt="flag">';
if($groupid == 1)
echo'
- Administrator';
if($groupid == 2 || $groupid == 3)
echo'
- Moderator';
if($groupid == 13)
echo' - Trusted Seller';
if($groupid == 15)
echo'
- Contributor of the Month';
if(!empty($mem['status']))
echo'
<div style="margin-bottom: 0.5ex;">Status:&nbsp;<span>'.$mem['status'].'</span></div>';
echo'
</li>
<li class="member_avatar">


',empty

($memberContext[$mem['id']]['avatar']['image'])

? '<img src="'.$settings['images_url'].'/noavatar.gif" width="50" height="50" />' : '<img height="50" width="50" src="' . $memberContext[$mem['id']]['avatar']['href'] . '"  alt="'.$mem['name'].'" />' ,'

</li>
<li class="member_rep">
<br /><br />Reputation: <span class="', ($mem['karmaTotal'] > 0) ? 'karma_pos' : 'karma_neg', '">'.$mem['karmaTotal'].'</span>
</li>
<li class="member_posts">
Posts: <span>'.$mem['post'].'</span>
</li>
<li class="member_votes">
Best answer votes received: <span>'.$mem['thank_you_post_became'].'</span>
</li>
<li class="member_points">
Points Earned: <span>'.$mem['money'].'</span>
</li>
<li class="member_since">
Team member since: <span>' . timeformat($mem['registered']). '<span>
</li>
<li class="member_active">
Last active: <span>' . timeformat($mem['login']). '</span>
</li>';
if($context['allow_pm'])
echo '
<li class="member_pm">
Send a <a href="'.$scripturl.'?action=pm;sa=send;u='.$mem['id'].'">personal message</a>
</li>';
echo '
</ul>
</li>';
}

echo'
</ul>';
}

Biology Forums

I managed to fix the problem if I added an extra <br /> to the

<br /><br />Reputation:

Is there another way though?

http://biology-forums.com/index.php?action=staff

Antechinus

Ah. Yup that would be a problem with the floats for the top section. I'll put the markup and css on a test page tonight with some filler content that doesn't rely on your variables, and play around with it a bit. Should be easy enough.

Biology Forums

Quote from: Antechinus on April 09, 2012, 06:53:16 PM
Ah. Yup that would be a problem with the floats for the top section. I'll put the markup and css on a test page tonight with some filler content that doesn't rely on your variables, and play around with it a bit. Should be easy enough.

Thanks plenty, Antechinus.

Advertisement: