turn username into a profile link
foxxie Offline
Junior Member
**
Posts: 9
Joined: Feb 2017
Post: #11
RE: turn username into a profile link
Whoops! I missed the bit below the code, sorry!
So far the field is ready, it works to choose the accounts, they are displayed everywhere where I wanted them. But they aren't turned into links.
02-16-2017 05:05 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #12
RE: turn username into a profile link
Without custom code modifications, this is really pushing what can be done with XThreads, but I suppose this could be possible, with a bunch of caveats.

You can set the Display Item Format to something like:

HTML Code
1
2
3
4
5
6
<setvar user>get_user_by_username({VALUE})</setvar>
<if $tplvars['user']['uid'] then>
 <?=build_profile_link({VALUE}, $tplvars['user']['uid'])?>
<else>
 {VALUE}
</if>

Caveats:
- get_user_by_username isn't a "safe" function, but if you have the PHP in Templates plugin, it should be allowed.  Alternatively, you can whitelist it by appending it to inc/xthreads/phptpl_allowed_funcs.txt
- it can run a query for every single user specified, which can place more load on the server

In theory, you could also do something similar using the Input Formatter to validate usernames, and store them as user IDs, but you still have the above caveats.


My Blog
(This post was last modified: 04-02-2017 09:10 PM by ZiNgA BuRgA.)
04-02-2017 09:09 PM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: