- Posts: 15
COMMUNITY FORUM
How to display username instead of full name
- Trond
-
Topic Author
- Offline
- New Member
Oslo, Norway.
Please Log in or Create an account to join the conversation.
- HomesteadMommy
-
- Offline
- Junior Member
- Posts: 27
Or when you go to publish your article, enter an author alias under author and publishing stats. To hide the email addresses you can disable that in the category or posts author options.
The first option would work well if people are likely to forget to change it when posting.
Please Log in or Create an account to join the conversation.
- Trond
-
Topic Author
- Offline
- New Member
- Posts: 15
Using only first name is not a good solution and the other one will generate to much support.
Is there a workaround for this one? I would like to link username back to Jomsocial as the best alternative if possible.
Oslo, Norway.
Please Log in or Create an account to join the conversation.
- bkemler
-
- Offline
- Premium Member
- Posts: 87
For displaying author usernames on the items they've written, you can change that in the templates. For example, in /templates/yourjoomlatemplate/html/com_k2/templates/yourk2template/item.php change
echo $this->item->author->name;
to
echo $this->item->author->username;
If you're using SH404SEF, you'll also need to change it in the k2 set_ext file.
I don't use comments so I couldn't tell you where to change it for that.
Trond said:Hi!
Using only first name is not a good solution and the other one will generate to much support.
Is there a workaround for this one? I would like to link username back to Jomsocial as the best alternative if possible.
Please Log in or Create an account to join the conversation.
- Trond
-
Topic Author
- Offline
- New Member
- Posts: 15
BUT: the URL's are still showing "name" instead of "username".
Does anybody know how to change "author" URL to show "username" instead of "name"?
We have to respect the users wishes to remain anonymous.
I've localized the file to edit (item.php) but shanging "author" to "username" or any other attemts to get this working has failed. Need help, please!
Thanks in advance!
Oslo, Norway.
Please Log in or Create an account to join the conversation.
- AdrianK
-
- Offline
- Senior Member
- Posts: 46
com_k2/templates/user.php, line 56
echo $this->user->name;
change name to username
Please Log in or Create an account to join the conversation.
- CFBPredictions.com
-
- Offline
- New Member
- Posts: 14
Also, if I click on the username in the item view to take me to the author page, the name shows up again in the url.
IMO, changing the name to show up as username needs to be a global parameter so we don't have to hack 9 files.
Titus said:You have to rename that in all other K2 templates too
com_k2/templates/user.php, line 56
echo $this->user->name;
change name to username
Please Log in or Create an account to join the conversation.
- AdrianK
-
- Offline
- Senior Member
- Posts: 46
The joomla MVC-architechture often use for view templates and view sub templates same and similar output structures and variables. It's not possible to put this variations together.
Please Log in or Create an account to join the conversation.
- vtiger
-
- Offline
- Premium Member
- Posts: 83
components\com_k2\helpers\route.php
function getUserRoute
at line 57
$alias = trim(mb_strtolower($user->name));
to
$alias = trim(mb_strtolower($user->username));
?
just guess...
Please Log in or Create an account to join the conversation.
- CFBPredictions.com
-
- Offline
- New Member
- Posts: 14
Lukas said:Trond said:the URL's are still showing "name" instead of "username".Does anybody know how to change "author" URL to show "username" instead of "name"?
components\com_k2\helpers\route.php
function getUserRoute
at line 57
$alias = trim(mb_strtolower($user->name));
to
$alias = trim(mb_strtolower($user->username));
?
just guess...
Please Log in or Create an account to join the conversation.
- AdrianK
-
- Offline
- Senior Member
- Posts: 46
open components/com_k2/view.html.php
Line 165
$title = $user->name;
to
$title = $user->username;
Please Log in or Create an account to join the conversation.
- CFBPredictions.com
-
- Offline
- New Member
- Posts: 14
Titus said:The breadcrumbs module takes the title. Hack the view. open components/com_k2/view.html.php
Line 165
$title = $user->name;
to
$title = $user->username;
Please Log in or Create an account to join the conversation.
- CFBPredictions.com
-
- Offline
- New Member
- Posts: 14
For anybody searching on how to change all of the name's to username's throughout K2 see this helpful post:
community.getk2.org/forum/topics/help-how-to-show-usenames-as?commentId=3536014%3AComment%3A25923
Please Log in or Create an account to join the conversation.
- Jeff Swope
-
- Offline
- New Member
- Posts: 9
B Kemler said:You'll have to change it in multiple places- it's not something that can be universally changed in one spot.
For displaying author usernames on the items they've written, you can change that in the templates. For example, in /templates/yourjoomlatemplate/html/com_k2/templates/yourk2template/item.php change
echo $this->item->author->name;
to
echo $this->item->author->username;
If you're using SH404SEF, you'll also need to change it in the k2 set_ext file.
I don't use comments so I couldn't tell you where to change it for that.
Trond said:Hi! Using only first name is not a good solution and the other one will generate to much support.
Is there a workaround for this one? I would like to link username back to Jomsocial as the best alternative if possible.
Please Log in or Create an account to join the conversation.
- Scott Simpson
-
- Offline
- New Member
- Posts: 6
any help would be much appreciated.
I can change them with ACESEF but i would rather the url's were created automaticly.
Please Log in or Create an account to join the conversation.
- Scott Simpson
-
- Offline
- New Member
- Posts: 6
(K2HelperRoute::getUserRoute($user->id)) which links the users " My Page " gets the url from the id which is changed into the " name " so there must be something i have missed. can anone advise?
Please Log in or Create an account to join the conversation.
- Trond
-
Topic Author
- Offline
- New Member
- Posts: 15
Oslo, Norway.
Please Log in or Create an account to join the conversation.
- william white
-
- Offline
- Platinum Member
- Posts: 3722
I bet you have to create an override directory, and then edit the user.php or other files to hide it by just commenting it out or changing the reference to full name to username...
Mabee when Simon returns he will have a quick fix...
in the mean time post a link to the exact page your are trying to work with
preferabl;y with sef turned off
Please Log in or Create an account to join the conversation.
- Scott Simpson
-
- Offline
- New Member
- Posts: 6
I have hit a snag though when the user logs in and clicks the " My Page " button from the user block, you will get the following error
"JUser::_load: Unable to load user with id: 65"
65 being what ever the user id is in the database. the changes i have made are below. take a look. I think the problem is i have removed the user id from the url query.
But at the very least the url is writing what we want to see. will play with this some more, and see what happens when i put the user id query back in the url.
see my changes below.
open k2_com folder, open the helpers, then open route.php and change the following, sorry i dont have line numbers.
change:
'name'=>(int)$userID
to
'username'=>(int)$userID
change.
$alias = trim(mb_strtolower($user->name));
to
$alias = trim(mb_strtolower($user->username));
and this
$link = 'index.php?option=com_k2&view=itemlist&task=user&id='.$userID.':'.$alias;
to
$link = 'index.php?option=com_k2&view=itemlist&task='.$alias;
Please Log in or Create an account to join the conversation.
- Scott Simpson
-
- Offline
- New Member
- Posts: 6
William i took your advice and turned the acesef url rewrite component off, and i get the following user url.
www.example.com/component/k2/itemlist/user/67-"username"
And the " username " is showing in the url instead of the " name " so i'm guessing that all the corrent changes to the k2 files are correct. " name " to " username " and the url change i made in the route.php file was not necessary.
// correct // $link = 'index.php?option=com_k2&view=itemlist&task=user&id='.$userID.':'.$alias;
to
// wrong // $link = 'index.php?option=com_k2&view=itemlist&task='.$alias;
So im guessing my problem is with the ACESEF component which is changing the "username" back to "name".
Please Log in or Create an account to join the conversation.