turn username into a profile link
foxxie Offline
Junior Member
**
Posts: 9
Joined: Feb 2017
Post: #9
RE: turn username into a profile link
Thank you!

So I tried to add a field for that in my test forum. For the moment with just the copied code of the private_send_autocomplete templated. I wanted to modify it afterwards so that I already have it if something goes wrong (what most likely will happen). But the first misstep came quicker than thought: I can't save the field. ^^

That's (so far) the code I wanted to put into the field you said:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<link rel="stylesheet" href="{$mybb->asset_url}/jscripts/select2/select2.css?ver=1807">
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/select2/select2.min.js?ver=1806"></script>
<script type="text/javascript">
<!--
if(use_xmlhttprequest == "1")
{
	MyBB.select2();
	$("#to").select2({
		placeholder: "{$lang->search_user}",
		minimumInputLength: 2,
		maximumSelectionSize: 8,
		multiple: true,
		ajax: { // instead of writing the function to execute the request we use Select2's convenient helper
			url: "xmlhttp.php?action=get_users",
			dataType: 'json',
			data: function (term, page) {
				return {
					query: term, // search term
				};
			},
			results: function (data, page) { // parse the results into the format expected by Select2.
				// since we are using custom formatting functions we do not need to alter remote JSON data
				return {results: data};
			}
		},
		initSelection: function(element, callback) {
			var query = $(element).val();
			if (query !== "") {
				var newqueries = [];
				exp_queries = query.split(",");
				$.each(exp_queries, function(index, value ){
					if(value.replace(/\s/g, '') != "")
					{
						var newquery = {
							id: value.replace(/,\s?/g, ", "),
							text: value.replace(/,\s?/g, ", ")
						};
						newqueries.push(newquery);
					}
				});
				callback(newqueries);
			}
		}
	});

  $("#bcc").select2({
		placeholder: "{$lang->search_user}",
		minimumInputLength: 2,
		maximumSelectionSize: {$mybb->usergroup['maxpmrecipients']},
		multiple: true,
		ajax: { // instead of writing the function to execute the request we use Select2's convenient helper
			url: "xmlhttp.php?action=get_users",
			dataType: 'json',
			data: function (term, page) {
				return {
					query: term, // search term
				};
			},
			results: function (data, page) { // parse the results into the format expected by Select2.
				// since we are using custom formatting functions we do not need to alter remote JSON data
				return {results: data};
			}
		},
		initSelection: function(element, callback) {
			var query = $(element).val();
			if (query !== "") {
				var newqueries = [];
				exp_queries = query.split(",");
				$.each(exp_queries, function(index, value ){
					if(value.replace(/\s/g, '') != "")
					{
						var newquery = {
							id: value.replace(/,\s?/g, ", "),
							text: value.replace(/,\s?/g, ", ")
						};
						newqueries.push(newquery);
					}
				});
				callback(newqueries);
			}
		}
	});
}
// -->
</script>


I'll get this error:

Quote:No multiple value delimiter defined (tip, you can set this to be a space).

I think I know where the problem is - is it the input formatter? By default there stands {VALUE}. What do I have to change?

Another question. Which ID do you mean? Do I have to put the one of the field into the script or the css-id like in the first row of the code?
02-15-2017 05:52 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
turn username into a profile link - foxxie - 02-08-2017, 07:57 AM
RE: turn username into a profile link - foxxie - 02-15-2017 05:52 AM

 Standard Tools
Forum Jump: