Simple Machines Community Forum

Customizing SMF => Graphics and Templates => Topic started by: pepa on February 01, 2018, 02:40:45 AM

Title: How to Create an Active Link in the Description Text for a Profile Field
Post by: pepa on February 01, 2018, 02:40:45 AM
I have a standard profile field which is only displayed to the user and admin.  I want to create an active link to another area of the forum in the description text for the profile field.  Tried using standard BBC code but doesn't do anything.  Anyone know how to do this?
Title: Re: How to Create an Active Link in the Description Text for a Profile Field
Post by: Sir Osis of Liver on February 01, 2018, 04:07:04 PM
You mean like this?

index.english.php



$txt['date_registered'] = '<a href="' . $scripturl . '?action=register">Date Registered</a>';



Title: Re: How to Create an Active Link in the Description Text for a Profile Field
Post by: pepa on February 01, 2018, 07:16:53 PM
Quote from: Sir Osis of Liver on February 01, 2018, 04:07:04 PM
You mean like this?

index.english.php



$txt['date_registered'] = '<a href="' . $scripturl . '?action=register">Date Registered</a>';



Sorry ... to be clearer.  When people view their forum profile they will see a Custom Profile Field to enter info into.  In the text description of that field I want to create an active URL they can click to navigate to the specific information posted in the forum.  The field and text description is:

Support the Spill
There will be a motion to Spill some board members at the AGM. Please indicate your support by entering: YES, NO, UNDECIDED. For more info read the Statement of Spill here: Community » General Category » AGM Spill » Spill Documents

I want to just display the text "For more info read the Statement of Spill" so that "Statement of Spill" is an active navigation link.  It's kind of clumsy the way I've done it currently having to enter the forum path to the info!
Title: Re: How to Create an Active Link in the Description Text for a Profile Field
Post by: Sir Osis of Liver on February 02, 2018, 12:41:12 PM
Hmm, not so easily done, would require some custom coding.  Will take a look at it tonight.
Title: Re: How to Create an Active Link in the Description Text for a Profile Field
Post by: Sir Osis of Liver on February 02, 2018, 10:29:52 PM
Profile.template.php



/// Are there any custom profile fields - if so print them!
if (!empty($context['custom_fields']))
{
if ($lastItem != 'hr')
echo '
<hr width="100%" size="1" class="hrcolor clear" />';

echo '
<dl>';

foreach ($context['custom_fields'] as $field)
{

if ($field['name'] == 'Support the Spill')
$field['desc'] = 'For more info read the <a href="https://www.google.com">Statement of Spill</a>';

echo '
<dt>
<strong>', $field['name'], ': </strong><br />
<span class="smalltext">', $field['desc'], '</span>
</dt>
<dd>
', $field['input_html'], '
</dd>';
}

echo '
</dl>';

}



Title: Re: How to Create an Active Link in the Description Text for a Profile Field
Post by: pepa on February 03, 2018, 12:13:59 AM
Yes, works a treat, thank you so much, I'm fast becoming indebted to you, you're incredibly helpful in this community .... kudos!