Support Forum

Forum and Topic View -Truncating very long usernames

CF Conrad_Farlow
Conrad_Farlow
Member

I am probably being really silly here and the fact is that most users are unlikely to have a problem but how can I truncate or limit a username in Forum and Topic Views?

For instance

sp_PostIndexUserName('tagClass=spPostUserName spCenter&truncate=50');

Does not work.

It is possible to have really long usernames such as hyphenated names that really mess up the appearance of both Topic and Forum View. We insist on real names for our forums and there are a couple of names that will cause problems with this.

Can it be fixed?

Conrad

9 Answers

New Answer

BR Brandon
Brandon
Member

There isn’t an argument available like that for truncating a user name like there is for a topic name.

I can see how this could cause you some formatting issues in several places depending on your layout.
Maybe the spTruncate function could be used to globally truncate a username instead of having to do so on every line that shows a user name.

I am sure Steve or Andy will pipe in with ideas.

MP Mr Papa
Mr Papa
Member

No afraid not… that might look quite odd… but we can consider it…

there is an sp function you can use on the returned value:  sp_truncate($name, $length)

and try to truncate it yourself… be careful, if you have it set to be a link though, the html will consume characters…

CF Conrad_Farlow
Conrad_Farlow
Member

I see that you have raised a ticket for this and it has been closed for incorporation into SP 5.05. When will that be released do you think?

Thanks as ever.

Conrad

YS Yellow Swordfish
Yellow Swordfish
Member

we are tentatively thinking next weekend at the moment. Depends if anything big crops up between then and now.

CF Conrad_Farlow
Conrad_Farlow
Member

I have upgraded so how do I implement the truncate user names feature?

BR Brandon
Brandon
Member

You would use truncateUser in each view file and set the length.

For example in GroupView.php to truncate to 5 for last post.

sp_ForumIndexLastPost('tagClass=spInRowPostLink&nicedate=1&date=0&time=0&stackdate=0&truncateUser=5', __sp('Last Post'), __sp('No Topics'));
MP Mr Papa
Mr Papa
Member

like the other truncation, but for users…  valid for:  sp_SubForumIndexLastPost, sp_TopicIndexFirstPost, sp_TopicIndexLastPost, sp_ForumIndexLastPost, sp_ListLastPost and sp_PostIndexUserName

CF Conrad_Farlow
Conrad_Farlow
Member

Yup implemented and working fine thanks.

MP Mr Papa
Mr Papa
Member

cool. thanks for the confirmation and update…