Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
abbreviate usernames in discussions overview so they don't exceed 6 characters (e.g. 'Userna...')
fh111
✭✭
how can i abbreviate usernames in discussions overview so they are not longer than 6 characters (e.g. 'Username' --> 'Userna...')
?
i am in applications/vanilla/views/discussions/helper_funtions.php
i tried to add
$short = substr_replace($Last, '...', 6);
and changed
echo '<span class="LastCommentBy">'.sprintf(T('Most recent by %1$s'), UserAnchor($Last)).'</span>';
to
echo '<span class="LastCommentBy">'.sprintf(T('Most recent by %1$s'), UserAnchor($short)).'</span>';
but it's giving me a 'bonk'
anyone know how to?
thanks
0
Answers
UserAnchor takes in FULL USER OBJECT detail rather than just passing the USERNAME.
for reference you can check the function UserAnchor in /library/core/functions.render.php around line 146.
since you are passing only username thats y you are getting bonk
There was an error rendering this rich post.
Woudnt you use strlen, string trim
There was an error rendering this rich post.
ok heres is the solution:
Your user is $Last
do:
$Last->Name = substr_replace($Last->Name, '...', 6);
and then you can use your line:
echo '< span class="LastCommentBy">'.sprintf(T('Most recent by %1$s'), UserAnchor($short)).'< /span>';
There was an error rendering this rich post.
ok heres is the solution:
Your user is $Last
do:
$Last->Name = substr_replace($Last->Name, '...', 6);
and then you can use your line:
echo '< span class="LastCommentBy">'.sprintf(T('Most recent by %1$s'), UserAnchor($Last)).'< /span>';
There was an error rendering this rich post.
thanks for your suggestions. i quickly tried your code sahotaran but it does not work. what's shown in the end is "..." as username and it links to the profile of "..." instead of the real user (which obviously does not exist) .. a problem i did not think of until now
Did you make sure what is the user you are passing? $Last is ur user variable or some other variable?
There was an error rendering this rich post.
$First and $Last are user variables, yes
I had given it a try on my local host and it seemed to work. I will give it a shot again
There was an error rendering this rich post.
i gave this another try but i can't get it work. still just showing '...' instead of the abbreviated usernames ..
any suggestions/ideas on how to get this done?
@fh111 said:
this is for last - (do the same thing for first replacing Last with First).
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
left out $Userid - the above will work because it doesn't matter if id is blank but below with userid corrected.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
@peregrine i wish i could press like 100 more times thanks so much!!!! this is going to make such a big difference for our community, i believe
big thanks
my pleasure.
I wish you could too(that is press like 100 times)! then I would surpass the supreme leader 422. .
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
let me prophecy this - you will for sure soon take over the lead with all the good help and support you give. you deserve it ..
Lol at supreme leader. Clicked like to both of you guys
There was an error rendering this rich post.
@supreme-leader I see your 1 and raise you 2
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
You should start a thread, the "like lottery"
There was an error rendering this rich post.
Well, I've seen what you've won from from having the highest points. . Is it really worth it.
I don't know if I could bear the load of all that fame and fortune. Mostly fortune - BTW did you get a big monetary increase from the developers . 1000 X 0 = 0!
I figured you should be able to ask one question of the developers for them to spend a bit of time to answer. - seems like that should have been the 1000 pt badge.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Uh huh, seemingly the only badges remaining are anniversary badges now.
There was an error rendering this rich post.
lol, raining likes here : )
@peregrine
i am trying to do the same with the discussion title, i want to abbreviate it to something like 56 characters or so, this is what i have now, following your example with the usernames. what i am struggeling with is the last part, where the url is put together in the 'a href' part. i can-t figure it out. it gives me
/discussion//the discussion title/
instead of
/discussion/DiscussionID/discussion-slug