Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: samborabora - heinäkuu 20, 2014, 05:07:47 AP

Otsikko: Display individual edit profile fields outside of the array?
Kirjoitti: samborabora - heinäkuu 20, 2014, 05:07:47 AP
I'm trying to rearrange some of the edit profile fields, and most of it has been possible reordering the array:
setupProfileContext(
array(
'avatar_choice', 'hr',
// 'personal_text', 'hr',
'location', 'hr', 'bday1', 'gender', 'hr',
'icq', 'aim', 'msn', 'yim', 'hr',
'usertitle',
//'signature', 'hr',
'karma_good', 'hr',
//'website_title',
'website_url',
)


But I'd like the signature edit field to appear below the custom profile fields which AREN'T displayed via the array. Any way of, say, creating a new array with the signature field in and calling that via the profile edit template?
Otsikko: Re: Display individual edit profile fields outside of the array?
Kirjoitti: samborabora - heinäkuu 21, 2014, 06:10:01 AP
For instance, I'd like to display a bit of html below the avatar bit, but above the location bit. Fine, I imagined I would just make a new array part based upon the 'hr' entry, and call it 'head1' or something, since the 'hr' entry just contains html, but that didn't work either.

Any ideas how to CALL different parts of this array into my profile edit view, and how to add parts the array that are made up of simple html?
Otsikko: Re: Display individual edit profile fields outside of the array?
Kirjoitti: margarett - heinäkuu 21, 2014, 06:32:35 AP
In that case you should probably edit Profile.template.php directly...

Something like:
Find:

', $context['member']['avatar']['image'], '
<ul class="reset">';

Add after:
//my custom HTML here
echo '
<li>Here comes my custom data</li>';
Otsikko: Re: Display individual edit profile fields outside of the array?
Kirjoitti: samborabora - heinäkuu 21, 2014, 08:44:49 AP
Lainaus käyttäjältä: margarett - heinäkuu 21, 2014, 06:32:35 AP
In that case you should probably edit Profile.template.php directly...

Something like:
Find:

', $context['member']['avatar']['image'], '
<ul class="reset">';

Add after:
//my custom HTML here
echo '
<li>Here comes my custom data</li>';


Is this for the "Edit Profile" part of the profile? Cause I wasn't sure if you could use those kinds of things in the edit profile part, only the "View Profile" section?
Otsikko: Re: Display individual edit profile fields outside of the array?
Kirjoitti: margarett - heinäkuu 21, 2014, 08:54:08 AP
Ah, yes, you're right... That's for the summary, not for the profile edit...

Is that custom HTML a field that is supposed to be stored or just an information bit?
Otsikko: Re: Display individual edit profile fields outside of the array?
Kirjoitti: samborabora - heinäkuu 21, 2014, 09:00:39 AP
It's just a <div></div> that says "info" above the fields, nothing complex, but I couldn't understand why I couldn't put it in as a new array? And, I want to place the signature textbox below the custom fields, which are handled by the template, rather than the array.
Otsikko: Re: Display individual edit profile fields outside of the array?
Kirjoitti: margarett - heinäkuu 21, 2014, 10:53:26 AP
I'm not too familiar with that, sorry...
Yet, I do think that only valid fields can go to the "setupProfileContext" array... So a div might not work there...
hr works because of this:

if ($field['type'] == 'hr')
{
echo '
</dl>
<hr width="100%" size="1" class="hrcolor clear" />
<dl>';
}

;)

If you look at the code at Profile.template.php, $field has some properties:
at least: name, value, type, subtext. Maybe you could fill "subtext" with your info? That's what the messengers use ;)

    [msn] => Array
        (
            [type] => text
            [label] => MSN
            [subtext] => Your MSN messenger email address
            [size] => 24
            [permission] => profile_extra
            [input_validate] => lambda_146
            [value] =>
            [input_attr] =>
        )

Otsikko: Re: Display individual edit profile fields outside of the array?
Kirjoitti: samborabora - heinäkuu 21, 2014, 11:05:23 AP
Lainaus käyttäjältä: margarett - heinäkuu 21, 2014, 10:53:26 AP
I'm not too familiar with that, sorry...
Yet, I do think that only valid fields can go to the "setupProfileContext" array... So a div might not work there...
hr works because of this:

if ($field['type'] == 'hr')
{
echo '
</dl>
<hr width="100%" size="1" class="hrcolor clear" />
<dl>';
}

;)

If you look at the code at Profile.template.php, $field has some properties:
at least: name, value, type, subtext. Maybe you could fill "subtext" with your info? That's what the messengers use ;)

    [msn] => Array
        (
            [type] => text
            [label] => MSN
            [subtext] => Your MSN messenger email address
            [size] => 24
            [permission] => profile_extra
            [input_validate] => lambda_146
            [value] =>
            [input_attr] =>
        )


Yeah, that first one was what I tried, taking the hr field and creating a new blank field, something like this (I just made this up, but it would be like this):


if ($field['type'] == 'infohead')
{
echo '
</dl>
<div id="infohead"><b>Info</b></div>
<dl>';
}


Then, trying to fit that into the array, like so:

setupProfileContext(
array(
'avatar_choice', 'hr',
// 'personal_text', 'hr',
'infohead',
'location', 'hr', 'bday1', 'gender', 'hr',
'icq', 'aim', 'msn', 'yim', 'hr',
'usertitle',
//'signature', 'hr',
'karma_good', 'hr',
//'website_title',
'website_url',
)


But it didn't work, and I can't figure exactly why. I'd also like to do something like:

setupSignature(
array(
'signature',
)


So I can keep it commented out in the main array, and call it at the end after the custom fields, but this also didn't work. Can I accomplish either of these in any way?
Otsikko: Re: Display individual edit profile fields outside of the array?
Kirjoitti: margarett - heinäkuu 21, 2014, 11:17:36 AP
The first doesn't work because there is no field called "infohead".

Signature has its own treatment, that's why it also doesn't work.
I'd need to study the code in depth to help you a bit more...
Otsikko: Re: Display individual edit profile fields outside of the array?
Kirjoitti: samborabora - heinäkuu 21, 2014, 11:23:57 AP
Lainaus käyttäjältä: margarett - heinäkuu 21, 2014, 11:17:36 AP
The first doesn't work because there is no field called "infohead".

Signature has its own treatment, that's why it also doesn't work.
I'd need to study the code in depth to help you a bit more...

Is it possible to define your own field, and therefore call it as part of the array? Or would it just be easier to call the different elements manually into the profile? If you can figure out how to call the signature field independently, that would be great, and I could probably just do the same for the other parts.
Otsikko: Re: Display individual edit profile fields outside of the array?
Kirjoitti: samborabora - heinäkuu 22, 2014, 01:25:26 IP
Lainaus käyttäjältä: margarett - heinäkuu 21, 2014, 11:17:36 AP
The first doesn't work because there is no field called "infohead".

Signature has its own treatment, that's why it also doesn't work.
I'd need to study the code in depth to help you a bit more...

It's probably easiest if I can just manually display everything the array displays in the profile editor without relying on the array, although this can probably have some sort of effect on the resources/are things like inputs and POST functions still avilable without calling the array?
Otsikko: Re: Display individual edit profile fields outside of the array?
Kirjoitti: margarett - heinäkuu 22, 2014, 02:13:03 IP
Dunno, really :(

I'll try to look at it. Unfortunately I'm extremely busy today :(
Otsikko: Re: Display individual edit profile fields outside of the array?
Kirjoitti: samborabora - heinäkuu 23, 2014, 05:51:17 AP
Lainaus käyttäjältä: margarett - heinäkuu 22, 2014, 02:13:03 IP
Dunno, really :(

I'll try to look at it. Unfortunately I'm extremely busy today :(

NO problem at all, I really appreciate you and anyone else that might have a chance to find out for me, I'm pretty new to arrays so I can't figure out where they're being called in exactly, or how to define new ones in this particular template. There must be some way of accomplishing this in the most efficient manner possible, surely?
Otsikko: Re: Display individual edit profile fields outside of the array?
Kirjoitti: samborabora - heinäkuu 26, 2014, 08:10:54 AP
So, I just need to get the signature box under the custom fields, and a bit of custom html in between the avatar selector and the rest of the input fields; there's only two ways I cant hink of doing this:


Not sure how to successfully accomplish either, as I said, if hr has been defined as a component of the array, there's no reason why some other html couldn't be defined in addition, I just can't work out how to do add anything to the array. But that would still not help with needing to position the signature box underneath the custom profile fields, which are external from the array.

Anyone know how this could work?
Otsikko: Re: Display individual edit profile fields outside of the array?
Kirjoitti: samborabora - elokuu 03, 2014, 04:18:31 AP
Will provide strange, personally satisfying pleasures in exchange for an answer for this one, it's just know to to take out or put in something from the edit profile array?
Otsikko: Re: Display individual edit profile fields outside of the array?
Kirjoitti: samborabora - elokuu 12, 2014, 05:16:45 AP
Okay, got the info header in, like so:

setupProfileContext(
      array(
         'infohead',
         'avatar_choice', 'hr',
         // 'personal_text', 'hr',
         'infimghd', 'location', 'hr', 'bday1', 'gender', 'hr',
         'icq', 'aim', 'msn', 'yim', 'hr',
         'usertitle',
         'signature', 'hr',
         'karma_good', 'hr',
         //'website_title',
         'website_url',
      )
   );
}

Then:
'infimghd' => array(
         'type' => 'none',
         'label' => '<span style="color: transparent;position:absolute;"><div id="infoheadimg"></div>',
         'subtext' => '</span>',
      ),

      'location' => array(
         'type' => 'text',
         'label' => $txt['location'],
         'log_change' => true,
         'size' => 50,
         'permission' => 'profile_extra',
         
      ),

Now to get the signature in the right place...
Otsikko: Re: Display individual edit profile fields outside of the array?
Kirjoitti: samborabora - elokuu 12, 2014, 05:22:55 AP
Done. I just removed this:

echo '

<dt>
<br />
<div id="sigheadimg"></div>
';

if ($context['show_spellchecking'])
echo '
<input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button_submit" />';

echo '
</dt>

<textarea class="editor" onkeyup="calcCharLeft();" name="signature" rows="5" cols="50">', $context['member']['signature'], '</textarea><br />';

/*// If there is a limit at all!
if (!empty($context['signature_limits']['max_length']))
echo '
<span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br />';*/

if ($context['signature_warning'])
echo '
<span class="smalltext">', $context['signature_warning'], '</span>';

// Load the spell checker?
if ($context['show_spellchecking'])
echo '
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/spellcheck.js"></script>';

// Some javascript used to count how many characters have been used so far in the signature.
echo '
<script type="text/javascript"><!-- // --><![CDATA[
function tick()
{
if (typeof(document.forms.creator) != "undefined")
{
calcCharLeft();
setTimeout("tick()", 1000);
}
else
setTimeout("tick()", 800);
}

function calcCharLeft()
{
var maxLength = ', $context['signature_limits']['max_length'], ';
var oldSignature = "", currentSignature = document.forms.creator.signature.value;

if (!document.getElementById("signatureLeft"))
return;

if (oldSignature != currentSignature)
{
oldSignature = currentSignature;

if (currentSignature.replace(/\r/, "").length > maxLength)
document.forms.creator.signature.value = currentSignature.replace(/\r/, "").substring(0, maxLength);
currentSignature = document.forms.creator.signature.value.replace(/\r/, "");
}

setInnerHTML(document.getElementById("signatureLeft"), maxLength - currentSignature.length);
}

addLoadEvent(tick);
// ]]></script>
';


From this:
// Show the signature editing box?
function template_profile_signature_modify()
{
global $txt, $context, $settings;

}


And dumped it into the profile.template.php where I wanted it to appear. Can't see why any of this wouldn't work, tbh :D
Otsikko: Re: Display individual edit profile fields outside of the array?
Kirjoitti: samborabora - elokuu 12, 2014, 05:50:10 AP
Except now it shoves signature inbetween the Secret Question Answer and Current Password box of Edit Settings also :/
Otsikko: Re: Display individual edit profile fields outside of the array?
Kirjoitti: samborabora - elokuu 12, 2014, 06:01:16 AP
Never mind, I wrapped it up inside
if (!empty($context['custom_fields']))
{


So, now it looks like a total mess, but does what it says on the tin :P