MyBB Community Forums

Full Version: {$customfields}
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
There is something regarding profile fields in the usercp.php thingie.
On line 242:
	"profile_fields" => $mybb->input['profile_fields']
And from 398 down:
// Custom profile fields baby!
	$altbg = "trow1";
	$requiredfields = '';
	$customfields = '';
	$query = $db->simple_select("profilefields", "*", "editable=1", array('order_by' => 'disporder'));
	while($profilefield = $db->fetch_array($query))
	{
		// Does this field have a minimum post count?
		if($profilefield['postnum'] && $profilefield['postnum'] > $user['postnum'])
		{
			continue;
		}

		$profilefield['type'] = htmlspecialchars_uni($profilefield['type']);
		$profilefield['name'] = htmlspecialchars_uni($profilefield['name']);
		$profilefield['description'] = htmlspecialchars_uni($profilefield['description']);
		$thing = explode("\n", $profilefield['type'], "2");
		$type = $thing[0];
		$options = $thing[1];
		$field = "fid{$profilefield['fid']}";
		$select = '';
		if($errors)
		{
			$userfield = $mybb->input['profile_fields'][$field];
		}
		else
		{
			$userfield = $user[$field];
		}
		if($type == "multiselect")
		{
			if($errors)
			{
				$useropts = $userfield;
			}
			else
			{
				$useropts = explode("\n", $userfield);
			}
			if(is_array($useropts))
			{
				foreach($useropts as $key => $val)
				{
					$val = htmlspecialchars_uni($val);
					$seloptions[$val] = $val;
				}
			}
			$expoptions = explode("\n", $options);
			if(is_array($expoptions))
			{
				foreach($expoptions as $key => $val)
				{
					$val = trim($val);
					$val = str_replace("\n", "\\n", $val);

					$sel = "";
					if($val == $seloptions[$val])
					{
						$sel = " selected=\"selected\"";
					}
					$select .= "<option value=\"$val\"$sel>$val</option>\n";
				}
				if(!$profilefield['length'])
				{
					$profilefield['length'] = 3;
				}
				$code = "<select name=\"profile_fields[$field][]\" size=\"{$profilefield['length']}\" multiple=\"multiple\">$select</select>";
			}
		}
		elseif($type == "select")
		{
			$expoptions = explode("\n", $options);
			if(is_array($expoptions))
			{
				foreach($expoptions as $key => $val)
				{
					$val = trim($val);
					$val = str_replace("\n", "\\n", $val);
					$sel = "";
					if($val == htmlspecialchars_uni($userfield))
					{
						$sel = " selected=\"selected\"";
					}
					$select .= "<option value=\"$val\"$sel>$val</option>";
				}
				if(!$profilefield['length'])
				{
					$profilefield['length'] = 1;
				}
				$code = "<select name=\"profile_fields[$field]\" size=\"{$profilefield['length']}\">$select</select>";
			}
		}
		elseif($type == "radio")
		{
			$expoptions = explode("\n", $options);
			if(is_array($expoptions))
			{
				foreach($expoptions as $key => $val)
				{
					$checked = "";
					if($val == $userfield)
					{
						$checked = " checked=\"checked\"";
					}
					$code .= "<input type=\"radio\" class=\"radio\" name=\"profile_fields[$field]\" value=\"$val\"$checked /> <span class=\"smalltext\">$val</span><br />";
				}
			}
		}
		elseif($type == "checkbox")
		{
			if($errors)
			{
				$useropts = $userfield;
			}
			else
			{
				$useropts = explode("\n", $userfield);
			}
			if(is_array($useropts))
			{
				foreach($useropts as $key => $val)
				{
					$seloptions[$val] = $val;
				}
			}
			$expoptions = explode("\n", $options);
			if(is_array($expoptions))
			{
				foreach($expoptions as $key => $val)
				{
					$checked = "";
					if($val == $seloptions[$val])
					{
						$checked = " checked=\"checked\"";
					}
					$code .= "<input type=\"checkbox\" class=\"checkbox\" name=\"profile_fields[$field][]\" value=\"$val\"$checked /> <span class=\"smalltext\">$val</span><br />";
				}
			}
		}
		elseif($type == "textarea")
		{
			$value = htmlspecialchars_uni($userfield);
			$code = "<textarea name=\"profile_fields[$field]\" rows=\"6\" cols=\"30\" style=\"width: 95%\">$value</textarea>";
		}
		else
		{
			$value = htmlspecialchars_uni($userfield);
			$maxlength = "";
			if($profilefield['maxlength'] > 0)
			{
				$maxlength = " maxlength=\"{$profilefield['maxlength']}\"";
			}
			$code = "<input type=\"text\" name=\"profile_fields[$field]\" class=\"textbox\" size=\"{$profilefield['length']}\"{$maxlength} value=\"$value\" />";
		}
		if($profilefield['required'] == 1)
		{
			eval("\$requiredfields .= \"".$templates->get("usercp_profile_customfield")."\";");
		}
		else
		{
			eval("\$customfields .= \"".$templates->get("usercp_profile_customfield")."\";");
		}
		$altbg = alt_trow();
		$code = "";
		$select = "";
		$val = "";
		$options = "";
		$expoptions = "";
		$useropts = "";
		$seloptions = "";
	}
	if($customfields)
	{
		eval("\$customfields = \"".$templates->get("usercp_profile_profilefields")."\";");
	}

	if($mybb->usergroup['cancustomtitle'] == 1)
	{
		if($mybb->usergroup['usertitle'] == "")
		{
			$query = $db->simple_select("usertitles", "*", "posts <='".$mybb->user['postnum']."'", array('order_by' => 'posts', 'order_dir' => 'DESC', 'limit' => 1));
			$utitle = $db->fetch_array($query);
			$defaulttitle = $utitle['title'];
		}
		else
		{
			$defaulttitle = $mybb->usergroup['usertitle'];
		}

		if(trim($user['usertitle']) == '')
		{
			$lang->current_custom_usertitle = '';
		}
		else
		{
			if($errors)
			{
				$newtitle = htmlspecialchars_uni($user['usertitle']);
				$user['usertitle'] = $mybb->user['usertitle'];
			}
		}
		eval("\$customtitle = \"".$templates->get("usercp_profile_customtitle")."\";");
	}
	else
	{
		$customtitle = "";
	}
	
	$plugins->run_hooks("usercp_profile_end");
	
	eval("\$editprofile = \"".$templates->get("usercp_profile")."\";");
	output_page($editprofile);
Hmm, I can't find it right now, but I'll carry on looking.

If anyone else knows which the file to edit is, make sure to post it. Saves my time haha. It's the file which carries all the variables.

To you last post, I'm not sure. I had to do it for my site (http://dubstepaddicts.com)

Look at the very bottom, and where you see "Social Sites", I had to do that myself, I couldn't find a plugin for it. I remember exactly how I did it, I just can't find the file I edited haha.

EDIT: Damn, I just realised. When I upgraded it took that out, so now I have to re-add that. ><

ANOTHER EDIT: Thought I'd found it, then didn't. :/
(2012-04-11, 11:57 PM)Deliver Wrote: [ -> ]Hmm, I can't find it right now, but I'll carry on looking.

If anyone else knows which the file to edit is, make sure to post it. Saves my time haha. It's the file which carries all the variables.

To you last post, I'm not sure. I had to do it for my site (http://dubstepaddicts.com)

Look at the very bottom, and where you see "Social Sites", I had to do that myself, I couldn't find a plugin for it. I remember exactly how I did it, I just can't find the file I edited haha.

EDIT: Damn, I just realised. When I upgraded it took that out, so now I have to re-add that. ><

ANOTHER EDIT: Thought I'd found it, then didn't. :/

This is the info your page displays:
Quote:<br />
<table border="0" cellspacing="0" cellpadding="5" class="tborder">
<tr>
<td class="thead"><strong>Social Sites</strong></td>
</tr>
<tr>
<td class="trow1"><!-- start: socialsites_site -->
<a href="facebook"><img src="icon" alt="Facebook" title="Dubstep on Facebook" /></a>
<!-- end: socialsites_site --><!-- start: socialsites_site -->
<a href="lastfm" target="_blank"><img src="icon" alt="Last.fm" title="Dubstep on Last.fm" /></a>
<!-- end: socialsites_site --><!-- start: socialsites_site -->
<a href="twitter" target="_blank"><img src="icon" alt="Twitter" title="Dubstep on Twitter" /></a>
<!-- end: socialsites_site --><!-- start: socialsites_site -->
<a href="youtube" target="_blank"><img src="icon" alt="YouTube" title="Dubstep on YouTube" /></a>
<!-- end: socialsites_site --></td>
</tr>
</table>
<!-- end: socialsites_profile -->

But this is indeed pretty much what im looking for to have such a field visible in the edit profile. But then to add the what i said in the way i want to. To display i would probably use something like this:

Template - Postbit Author User:

{$lang->postbit_posts} {$post['postnum']}<br />
{$lang->postbit_joined} {$post['userregdate']}<br />
{$post['fid5']}<br />

<!--Main-->
<!--class = 8 -->
<!--character = 4-->
<!--Realm = 6-->

<if $post['fid4'] then>
<a href="http://eu.battle.net/wow/en/character/{$post['fid6']}/{$post['fid4']}/simple" />
<img src="images/classicons/{$post['fid8']}.png" title = {$post['fid8']} />
{$post['fid4']}&nbsp;{$post['fid6']}
</a><br />
</if>

<!--Alt 1-->

<if $post['fid10'] then>
<a href="http://eu.battle.net/wow/en/character/{$post['fid11']}/{$post['fid10']}/simple" />
<img src="images/classicons/{$post['fid9']}.png" title = {$post['fid9']} />
{$post['fid10']}&nbsp;{$post['fid11']}
</a><br />
</if>

<!--Alt 2-->

<if $post['fid13'] then>
<a href="http://eu.battle.net/wow/en/character/{$post['fid14']}/{$post['fid13']}/simple" />
<img src="images/classicons/{$post['fid12']}.png" title = {$post['fid12']} />
{$post['fid13']}&nbsp;{$post['fid14']}
</a><br />
</if>

<!--Alt 3-->

<if $post['fid16'] then>
<a href="http://eu.battle.net/wow/en/character/{$post['fid17']}/{$post['fid16']}/simple" />
<img src="images/classicons/{$post['fid15']}.png" title = {$post['fid15']} />
{$post['fid16']}&nbsp;{$post['fid17']}
</a><br />
</if>

<!--Alt 4-->

<if $post['fid19'] then>
<a href="http://eu.battle.net/wow/en/character/{$post['fid20']}/{$post['fid19']}/simple" />
<img src="images/classicons/{$post['fid18']}.png" title = {$post['fid18']} />
{$post['fid19']}&nbsp;{$post['fid20']}
</a><br />
</if>

Which i currently use for the avatar to display the filled in fields.

But for that part i would need to edit the usercp_profile template i think not even sure. To change it to the way you want to. But the thing i want to change atleast right now is the way the edit profile template (additional information box) looks. Or add a complete new box with said options.
I honestly can't remember which file it was. Any support team want to step in? You know? Do your job? Haha, just kidding, this is getting frustrating as I need the help also lolol.
You may find this add-on for Xthreads to be close to what you are looking for:

http://mybbhacks.zingaburga.com/showthread.php?tid=1271
(2012-04-12, 10:24 AM)Leefish Wrote: [ -> ]You may find this add-on for Xthreads to be close to what you are looking for:

http://mybbhacks.zingaburga.com/showthread.php?tid=1271

The MyCode part could be usefull, but still does that let you rearrange them at the input part?

Doesnt really show any screenshots of that part. Or what it does with the customfields. And honestly would have hoped i could have achieved this by maybe editing some core PhP files. Or having the option to add another box (not called additional information) and simply use tables etc to display the input fields (the customfields) and parse that information just like it is done now.
Well, it will allow you to show the fields with BB code on both profile and postbit. You can edit where they are placed on the register form - but you have to do that yourself.

I am using it - I have a policy box for my uploaders that they fill in - I called the field policy as you can give the field a name - and I have it so that you can view it from the postbit, even though I have profiles hidden from guests.

http://www.leefish.nl/mybb/thread-3308.html << click on the "Click to View leefish's Terms of Use" in the blue bar near the bottom. You will see it has BBCode formatting. The popup is not included in the plugin.

In this post on MYBBHacks it has some screenshots http://mybbhacks.zingaburga.com/showthre...6#pid10656
Pages: 1 2