Keyword

How to show username in comments and real author name in articles?

More
14 years 6 months ago #81088 by DKcrm
Hello

 

Does anybody know how to show the username for comments and the authorname for written articles?

 

On our site, www.interclub.dk we have K2 powered articles and comments - How do we show the user's usernames instead of their real names in the comments while keeping the real names for authors of the articles??






Well, after not getting a reply on this, I decided to add some comments..

I have found THIS thread, and a post by B Kemler, suggesting changes to the PHP files to show USER names on articles. I've followed the steps, and succesfully managed to change authors on articles to usernames instead of 'real' names.

In hope that the procedure would be the same for the comments, I tried changing the strings for the comments, but found that they already are called 'userName' - Changing to 'username' or 'name' completely deletes the names in itemview, which of course was not of any help at all, so I changed them back.



I've been trying to go through the different php files of k2 in hope to find the place to make the change - but without success. Isn't there anybody at all, who knows how to keep the real author names on the articles, but to only show USER names in the articles?

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #81089 by trip
Hi Christoffer
did you manage to solve this ?

Matthew

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #81090 by DKcrm
Hi Matthew

Unforunately no - Do you have a solution or are you stuck the same place as me?

Kr,
Christoffer

Matthew said:Hi Christoffer did you manage to solve this ?

Matthew

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #81091 by Matthew Philogene
Hi
The issue is the main table where the user details of K2 are stored do not contain the username...
I have tried to use joomla core to bring this through, but no luck... going to ask Fotis, when he gets a chance...
will let you know
Matthew



Christoffer Müller said:Hi Matthew
Unforunately no - Do you have a solution or are you stuck the same place as me?

Kr,
Christoffer

Matthew said:Hi Christoffer did you manage to solve this ?
Matthew

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #81092 by Lefteris
Hi. You can achieve that using a little of PHP and the Joomla! API. You can try this inside your template file at the comment loop:

$commentUser = &JFactory::getUser($comment->userID); echo $commentUser->username;

It's not the most efficient way but currently it's the only way to do this.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #81093 by trip
Hi there
thanks this has worked.... is it not possible to add this as a field in the K2 user profile, and make it an option to show or hide ?

Matthew

Lefteris Kavadas said:Hi. You can achieve that using a little of PHP and the Joomla! API. You can try this inside your template file at the comment loop:
$commentUser = &JFactory::getUser($comment->userID); echo $commentUser->username;

It's not the most efficient way but currently it's the only way to do this.

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #81094 by DKcrm
Ohh... As it seems to be working for Matthew, I would like to get some more details on where to add this exactly?

Am I working in the Joomla template files, or the components/com_k2/views/comments/tmpl/ - or somewhere else? (maybe item.php under /components/com_k2/templates/default/ ?)

Further help much appreciated :o)

Christoffer


Lefteris Kavadas said:Hi. You can achieve that using a little of PHP and the Joomla! API. You can try this inside your template file at the comment loop:
$commentUser = &JFactory::getUser($comment->userID); echo $commentUser->username;

It's not the most efficient way but currently it's the only way to do this.

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #81095 by Matthew Philogene
Hi

goto the file

item.php

search for the words "posted by" there is a line of code which echoes the userName

replace with code above

Hope this helps, as we cannot give exact line of code due to huge change in code..

Matthew

Christoffer Müller said:Ohh... As it seems to be working for Matthew, I would like to get some more details on where to add this exactly?
Am I working in the Joomla template files, or the components/com_k2/views/comments/tmpl/ - or somewhere else? (maybe item.php under /components/com_k2/templates/default/ ?)

Further help much appreciated :o)

Christoffer


Lefteris Kavadas said:Hi. You can achieve that using a little of PHP and the Joomla! API. You can try this inside your template file at the comment loop: $commentUser = &JFactory::getUser($comment->userID); echo $commentUser->username;

It's not the most efficient way but currently it's the only way to do this.

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #81096 by JoomlaWorks
This is something that can be added on your Joomla! template really, in the place where you override the MVC template of the module. We'll add it in 2.4 as an option on mod_k2_comments ;)

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #81097 by DKcrm
Hi all - and thank you all for your help in this matter...

It seems to be working now, following the solution given above.. It took some time figuring out which bit of code to change as there were 3 statements like 'echo $comment->userName;' following each other..

If others wants the same change, the item.php (in my case) file is located under [J!installation]/templates/[your template folder]/html/com_k2/templates/default/
- the bit of (working) code looks like the attached picture

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum