Customizing SMF > Mod Requests
Custom profile fields in Who is online and Memberlist
live627:
Yep - that's the one! It needs refit to use Curve, though.
HunterP:
--- Quote from: live627 on July 10, 2012, 07:50:56 PM ---Yep - that's the one! It needs refit to use Curve, though.
--- End quote ---
Already got it working, thanks :)
HunterP:
Can anyone tell me why the number of messages sort correctly, like :
0
1
2
10
But the custom fields sort like if they are treated als alphanumeric :
0
1
10
2
In fact, these fields are only numeric. Any ideas on this?
Sorck:
--- Quote from: HunterP on July 11, 2012, 02:04:08 PM ---
Can anyone tell me why the number of messages sort correctly, like :
0
1
2
10
But the custom fields sort like if they are treated als alphanumeric :
0
1
10
2
In fact, these fields are only numeric. Any ideas on this?
--- End quote ---
SMF stores them as a string rather than as an integer therefore when sorting them it will do so alphabetically.
It would be possible to adjust SMF to sort those columns properly but it would only work in MySQL I think.
http://www.kreci.net/web-development/sort-varchar-as-int-in-mysql-query/ for some information. http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html#function_cast covers the MySQL docs for the function. I'm not sure how efficient this will be though...
HunterP:
Sounds interesting, but I can't find ORDER anywhere, I did find this piece of code :
--- Code: --- // Build up sort queries.
if ($row['field_type'] != 'check')
$context['custom_profile_fields']['sort'][$curField] = array(
'down' => 'LENGTH(t' . $curField . '.value) > 0 ASC, IFNULL(t' . $curField . '.value, 1=1) DESC, t' . $curField . '.value DESC',
'up' => 'LENGTH(t' . $curField . '.value) > 0 DESC, IFNULL(t' . $curField . '.value, 1=1) ASC, t' . $curField . '.value ASC'
);
else
$context['custom_profile_fields']['sort'][$curField] = array(
'down' => 't' . $curField . '.value DESC',
'up' => 't' . $curField . '.value ASC'
);
// Did they make a magical selection?
if (isset($_REQUEST['sort']) && $_REQUEST['sort'] == $curField)
{
$context['custom_profile_fields']['join'] = 'LEFT JOIN {db_prefix}themes AS t' . $curField . ' ON (t' . $curField . '.variable = {string:t' . $curField . '} AND t' . $curField . '.id_theme = 1 AND t' . $curField . '.id_member = mem.id_member)';
$context['custom_profile_fields']['parameters']['t' . $curField] = $row['col_name'];
}
}
--- End code ---
Any suggestions how to modify this?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version