I have SMF 2.0RC3 custom profiles feature enabled with the ability for users to add icons to their profiles by checking a box in their profile. This works great when viewing the users profile in a thread, however, when opening that users profile it shows all icons regardless if they're checked or not. I also noticed that even if these fields are empty that the <li></li> will also be printed. Probably because of the || in the below code.
default\Profile.template.php
// Are there any custom profile fields for the summary?
if (!empty($context['custom_fields']))
{
foreach ($context['custom_fields'] as $field)
if ($field['placement'] == 1 || empty($field['output_html']))
echo '
<li>', $field['output_html'], '</li>';
}
I tried comparing the above code with what is in the display.template.php and noticed that it's $context['member']['custom_fields'] but changing the code to how it is in the display.template.php doesn't seem to work, just shows no icons even if they're checked.
This is an Example page (http://www.computerhope.com/forum/index.php?action=profile;u=72330), on this users profile it should not be showing any of the last four icons as they're all unchecked in the users profile.
Since I haven't got a reply spent some time debugging this and found the fix. Here is how I fixed this.
I looked at the array using print_r ($context['custom_fields']) which showed me arrays like the one shown below.
[0] => Array
(
[name] => F@H
[desc] => Folding @ Home user
[type] => check
[input_html] => <input type="checkbox" name="customfield[cust_f]" class="input_check" />
[output_html] => <a href="URL"><img src="folding.gif" alt="F@H member" /></a>
[placement] => 1
[colname] => cust_f
[value] => 0
)
As can be seen I have HTML data, but the value is 0 (e.g. box is not checked). So even though this isn't checked it's still going to show using the original SMF code. To fix this I changed it so if the value is not 0 (checked) AND is not empty then echo the data.
// Are there any custom profile fields for the summary?
if (!empty($context['custom_fields']))
foreach ($context['custom_fields'] as $field)
if ($field['placement'] == 1 && !$field['value'] == 0 && !empty($field['value']))
echo '
<li>', $field['output_html'], '</li>';
Hope this helps, if this isn't already fixed in RC4 would highly recommend it.
Sorry for the delay, mrhope, and thank you very much for the report.
Last minute bump program! :P (sorry for the late bump, but I completely forgot about them... :-[)
Updated fix:
// Are there any custom profile fields for the summary?
if (!empty($context['custom_fields']))
{
foreach ($context['custom_fields'] as $field)
if ($field['placement'] == 1 || empty($field['output_html']))
// Are there any custom profile fields for the summary?
if (!empty($context['custom_fields']))
{
foreach ($context['custom_fields'] as $field)
if (($field['placement'] == 1 || empty($field['output_html'])) && !empty($field['value']))
These last minute bumps should have been tracked to Mantis.
/me grumbes about hiding reports in obscure places.............
ETA: Sorted it.
Sorry for not tracking it... :-[