News:

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

Main Menu

[TIP/TRICK] Inline Custom Profile fields Above Signature

Started by GL700Wing, October 19, 2018, 01:13:22 AM

Previous topic - Next topic

GL700Wing

By default when more than one Custom Profile field is displayed above the signature each field is shown on a separate line.  I wanted the option to show multiple Custom Profile fields on the same line (with a separating character) and/or to display them on separate lines.

To start with I needed to control the order in which the Custom Fields will be displayed so I installed the mod Order Custom Profile Fields.

I then made a minor change as the mod didn't work properly with SMF 2.0.15.
In ./Sources/ManageSettings.php:
Find:
<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/ordercustomprofilefields/jquery.js?1.4.2"></script>
<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/ordercustomprofilefields/jquery.tablednd.js?0.5"></script>';


Replace with:
<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/ordercustomprofilefields/jquery.js"></script>
<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/ordercustomprofilefields/jquery.tablednd.js"></script>';





Several templates needed to be changed so that instead of the fields being displayed inside 'list' tags they are displayed inside 'span' tags.

In ./Themes/default/Display.template.php:
Find:
echo '
<div class="custom_fields_above_signature">
<ul class="reset nolist">';
}
echo '
<li>', $custom['value'], '</li>';
}
if ($shown)
echo '
</ul>
</div>';


Replace With:
echo '
<div class="custom_fields_above_signature">';
}
echo '
<span>', $custom['value'], '</span>';
}
if ($shown)
echo '
</div>';


In ./Themes/default/PersonalMessage.template.php:
Find:

echo '
<div class="custom_fields_above_signature">
<ul class="reset nolist">';
}
echo '
<li>', $custom['value'], '</li>';
}
if ($shown)
echo '
</ul>
</div>';


Replace With:

echo '
<div class="custom_fields_above_signature">';
}
echo '
<span>', $custom['value'], '</span>';
}
if ($shown)
echo '
</div>';



In ./Themes/default/Profile.template.php:
Find:

echo '
<div class="custom_fields_above_signature">
<ul class="reset nolist">';
}
echo '
<li>', $field['output_html'], '</li>';
}
if ($shown)
echo '
</ul>
</div>';


Replace With:

echo '
<div class="custom_fields_above_signature">';
}
echo '
<span>', $field['output_html'], '</span>';
}
if ($shown)
echo '
</div>';






As a result of the changes to the template files multiple Custom Profile fields displayed above the signature are now, by default, displayed on a single line without any separating characters.  However, by including separating text (eg, ' | ') and/or the '<br/>' tag in the 'Show Enclosed Within Text' field when creating/updating a Custom Profile field the fields can be displayed as required.

In the first image you can see the order of the Custom Profile Fields - the display order was set using the Order Custom Profile Fields mod.

In the second and third images you can see this tip/trick in use as displayed in messages and profile summaries.

The value of the Show Enclosed Within Text field for each Custom Profile field is as follows inside the '"' characters:
Joined Old Forum #1: "<b>Joined Old Forum #1:</b> {INPUT}"
Prev Model #1: " | <b>Previous Model #1:</b> {INPUT}"
Prev Year #1: " | <b>Previous Year #1:</b> {INPUT}
Joined Old Forum #2: "<br/><b>Joined Old Forum #2:</b> {INPUT}"
Prev Model #2: " | <b>Previous Model #2:</b> {INPUT}"
Prev Year #2: " | <b>Previous Year #2:</b> {INPUT}"

Note: The '<br/>' tag at the start of Joined Old Forum #2 causes this Custom Profile field to start on a new line.
Life doesn't have to be perfect to be wonderful ...

Advertisement: