Additional Settings For Custom Profile Fields [1.2]
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #71
RE: Additional Settings For Custom Profile Fields
I don't know what is the best method to use the input. I think it depends on how the layout you want and how you want to modify your usercp_profile template.

Please remember that by default, for the inputs, this plugin doesn't touch a required field, except for the Regular Expression setting (I don't want to remove it, because I really need the regular expression for some of my textbox). So, if you want to modify your usercp_profile template, try to think where the required field should be displayed (for example if you want to use tabs in the template) first.

Some references in this thread:
If we want displaying the input manually in usercp_profile template:
http://mybbhacks.zingaburga.com/showthre...http://mybbhacks.zingaburga.com/showthread.php?tid=1271&pid=1118
Creating textarea or textbox input manually (using {VALUE} element):
http://mybbhacks.zingaburga.com/showthre...http://mybbhacks.zingaburga.com/showthread.php?tid=1271&pid=1091
Displaying a default textarea and/or textbox (using {INPUT} element):
http://mybbhacks.zingaburga.com/showthre...http://mybbhacks.zingaburga.com/showthread.php?tid=1271&pid=1140

Basically, for textarea and textbox, if we want to use textarea or text input tags, we can use {VALUE} for the value of the input. With this way, we can modify the input (for example, we can use our textbox as color picker or date picker - validate it using the Regular Expression setting).

For the checboxes and/or radio buttons, here is a simple example for modifying it:
  • Title: Favourite Games
  • Short Description: What is your favourite games?
  • Selectable Options?

    Code:
    Morrowind
    Oblivion
    Never Winter Night 2
    Gothic 3
    Final Fantasy VII

  • Custom Input:

    HTML Code
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    <br />
    <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
    	<tr>
    		<td class="thead">
    			<div class="float_right smalltext"><func htmlspecialchars_uni>{$xtpf_data['description']}</func></div>
    			<strong><func htmlspecialchars_uni>{$xtpf_data['name']}</func></strong>
    		</td>
    	</tr>
    	<tr>
    		<td class="trow1">
    			<div class="float_left">{VALUE$1}</div>
    			<div class="float_left">{VALUE$2}</div>
    			<div class="float_left">{VALUE$3}</div>
    			<div class="float_left">{VALUE$4}</div>
    			<div class="float_left">{VALUE$5}</div>
    		</td>
    	</tr>
    </table>

  • Formatting Map List:

    Code:
    Morrowind{|}<img src="images/myimages/morrowind.jpg" alt="Morrowind" title="Morrowind" />
    Oblivion{|}<img src="images/myimages/oblivion.jpg" alt="Oblivion" title="Oblivion" />
    Never Winter Night 2{|}<img src="images/myimages/nwn2.jpg" alt="Never Winter Night 2" title="Never Winter Night 2" />
    Gothic 3{|}<img src="images/myimages/gothic3.jpg" alt="Gothic 3" title="Gothic 3" />
    Final Fantasy VII{|}<img src="images/myimages/ff7.jpg" alt="Final Fantasy VII" title="Final Fantasy VII" />

  • Display Format:

    Code:
    {VALUE$1} {VALUE$2} {VALUE$3} {VALUE$4} {VALUE$5}

In usercp_profile page:
   

In profile page (if we don't hide it):
   

Unfortunately, I can't help much with it because I think it's a subjective taste.

As I said in the first post, I'm not a coder, so I can't make it as a complex system. I really hope later we'll have a complex system like XThreads for custom profile fields.

I'm sorry if I misunderstand what you mean, Lee.

08-08-2012 03:11 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #72
RE: Additional Settings For Custom Profile Fields
Yes, I have a specific issue that I am trying to work on, maybe that would help a bit more.

I have a customfield "what is your cue" (my idea was later to query on that and give some silly stats like "did you know that x percent of members use a house cue" ) so I was trying to keep the selection simple, to minimise strain later. However, there are a LOT of cue manufacturers, and I don't want to be that granular in the data I query, but I do want users to have the opportunity to add their cue if it is not in the list.

I was unsure how to approach this; I don't want them to have a field saying "what is your model of cue" if they have selected house cue in the list as that is silly; it is more that IF they select "custom cue" then the option to enter data in an additional text field appears. That would be another profile field I think as we cannot mix and match field types.

Is that possible? If option A is chosen in customfield 1 then customfield 2 becomes visible without a page reload?


[Image: leelink.gif]
MYBB1.6 & XThreads
08-08-2012 05:56 PM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #73
RE: Additional Settings For Custom Profile Fields
(08-08-2012 05:56 PM)leefish Wrote:  Is that possible? If option A is chosen in customfield 1 then customfield 2 becomes visible without a page reload?
You can use javascript for that. Put it inside the Display Format. By default, MyBB doesn't assign an ID for each input. Because this plugin doesn't touch a required field, so an ID assigned for a non required field only by this plugin.
For Option Buttons, the ID is fidX_Y, where X is the custom profile field ID, and Y is the option order (the first option is 1).
For other input type, the ID is xtpf_fidX, where X is the custom profile field ID.

Then maybe you need to create a plugin to validate it in a server side.

(08-08-2012 05:56 PM)leefish Wrote:  my idea was later to query on that and give some silly stats like "did you know that x percent of members use a house cue"
Please remember that MyBB always assign TEXT as data type for each custom profile fields, no matter what type the input is.

08-09-2012 05:16 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #74
RE: Additional Settings For Custom Profile Fields
Yea, I think I can do the JS if  can work out which bit is which, I know how to open a div on click and that sort of thing, but I am not sure how to build the form using the defined inputs from the fields.

I will have a look further Biggrin

On the search - yes, it is not ideal, but surely better to search for a specific TEXT than a wild card?


[Image: leelink.gif]
MYBB1.6 & XThreads
08-09-2012 09:03 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #75
RE: Additional Settings For Custom Profile Fields
(08-09-2012 09:03 AM)leefish Wrote:  build the form using the defined inputs from the fields.
There is an example in XThreads file input type, inside the Input Field HTML setting.

(08-09-2012 09:03 AM)leefish Wrote:  but surely better to search for a specific TEXT than a wild card?
Do you mean like filter?

BTW, thanks for the MyBB's default smilies as png:
http://mods.mybb.com/view/mybb-smilies-as-png
I've just found it and download it.

08-10-2012 05:57 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #76
RE: Additional Settings For Custom Profile Fields
I mean that if I have a plugin that makes a simple report and I do a query on the field value then it is better to look for a specific value rather than using wildcards? Like the % symbol in the " AND t.closed NOT LIKE 'moved|%' " that we use in many queries is not an efficient way to query. It is hard to avoid it in those queries because of the way the MYBB Table is made, but if we can avoid making our data require such a wildcard then the query is faster on the db.

So for example, "did you know that 37% of members use a custom cue?" If I have an input field for a profile field and I want to query on only one value from that profile field set then we are querying by text, so I want to have an input for custom cue. That is for query purposes. Then, when that input "custom cue" in the "type of cue" profile field is selected then ANOTHER custom profile field opens and they can put the data in a textarea.

Now, I know how to open a hidden div by "watching" for the on change event in an input, but as I only want that hidden div to open if they click on only one option from the 1st list then I need to know the id of the field they have clicked on - the input id for that item in the profile field list of inputs.

For example - in the what is your favourite game layout you shared - what if there was a sixth value - other game - and when that was clicked they could fill in a textarea with the Name of the favourite game? That textarea would actually be ANOTHER profilefield, but only visible if the 6th option of the favourite games was clicked.

I am trying to find the example.


[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 08-12-2012 11:56 PM by leefish.)
08-12-2012 11:19 PM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #77
RE: Additional Settings For Custom Profile Fields
(08-12-2012 11:19 PM)leefish Wrote:  I mean that if I have a plugin that makes a simple report and I do a query on the field value then it is better to look for a specific value rather than using wildcards? Like the % symbol in the " AND t.closed NOT LIKE 'moved|%' " that we use in many queries is not an efficient way to query. It is hard to avoid it in those queries because of the way the MYBB Table is made, but if we can avoid making our data require such a wildcard then the query is faster on the db.
I think the query will be faster if you use index/key in the "requested" fields (in your case above). That's why I told you that by default, MyBB always assigns TEXT as data type for each custom thread field columns, because (I think) you need to do a "special thing" if you want to assign an index for TEXT/BOLB columns.

(08-12-2012 11:19 PM)leefish Wrote:  Now, I know how to open a hidden div by "watching" for the on change event in an input, but as I only want that hidden div to open if they click on only one option from the 1st list then I need to know the id of the field they have clicked on - the input id for that item in the profile field list of inputs.
I've posted the ID provided by this plugin in my previous post.

(08-12-2012 11:19 PM)leefish Wrote:  For example - in the what is your favourite game layout you shared - what if there was a sixth value - other game - and when that was clicked they could fill in a textarea with the Name of the favourite game? That textarea would actually be ANOTHER profilefield, but only visible if the 6th option of the favourite games was clicked.
If you use checkboxes, the ID is the same as the Option Buttons ID.

08-13-2012 02:27 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #78
RE: Additional Settings For Custom Profile Fields
I worked it out - thanks - now to get the field to hide when on change of the other buttons - or a toggle. I went with radio buttons as I only want one option chosen. I was a bit bewildered by the previous post as I did not really understand you at all. I finally discovered after some trial and error that in the display format I needed to have :

Code:
{VALUE$1} {VALUE$2} {VALUE$3} {VALUE$4} {VALUE$5}
{VALUE}


to show the output on the Profile (not user cp). No idea why that is. Frown
So, the final working code (scraffly right now)

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
{$customfields}{$xtpf_inp['fid10']}

<script type="text/javascript">
 var el = document.getElementById('fid10_4');
 if (el)
 el.onchange = function() 
 {document.getElementById('thing').style.display = "block";}
 else
 alert("element not found");
 </script>
<div id="thing" style="display:none;">
{$xtpf_inp['fid11']}
</div>


I still don't get what you mean re the query. Sorry.



[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 08-13-2012 03:56 AM by leefish.)
08-13-2012 03:54 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #79
RE: Additional Settings For Custom Profile Fields
For option buttons, you only need to put {VALUE} inside the Display Format.

08-14-2012 03:13 AM
Find all posts by this user Quote this message in a reply
Sama34 Offline
Senior Member
****
Posts: 490
Joined: May 2011
Post: #80
RE: Additional Settings For Custom Profile Fields
Do you remember this RateU?:

The same issue happens with this plugin Erf. Tough it can be other plugin fault, I just found a "solution" to this, open ./usercp.php, find:

PHP Code:
	if($errors)
	{
		$user = $mybb->input;
		$bday = array();


Replace with:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
	if($errors)
	{
		foreach((array)$mybb->input as $key => $val)
		{
			if(isset($mybb->user[$key]))
			{
				$mybb->user[$key] = $val;
			}
		}
		$user = $mybb->user;
		$bday = array();


I just can't find the plugin causing this yet No.


Support PM's will be ignored. Yipi
Plugins: Announcement Bars - Custom Reputation - Mark PM As Unread
08-20-2012 06:10 AM
Visit this user's website Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: