- Posts: 214
COMMUNITY FORUM
display comment author username not name
- George Nasis
-
Topic Author
- Offline
- Elite Member
i notice that in comments, what is displayed is the commenter`s name and not username. although in item.php
there is
Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
You need to do a var_dump of $comment and check if the object contains that element.
If it doesn't then you will have to do a custom SQL query.
Please Log in or Create an account to join the conversation.
- George Nasis
-
Topic Author
- Offline
- Elite Member
- Posts: 214
thanks for the response!
the table of the cooments contains itemID(the item where the comment done), userID, and userName(the realname) and other information which don`t help
i am not familiar with this one..
does anyone know how to retrieve the username of userID of this table?or from the table with items?
in mod_k2_comments there is option if username or name will be displayed, but in comments.php the code is
Log in or Create an account to join the conversation.
- Bart Coenen
-
- Visitor
Did you find a solution to this? I have the same wish (would like to display the username, not the name).
Please Log in or Create an account to join the conversation.
- George Nasis
-
Topic Author
- Offline
- Elite Member
- Posts: 214
nothing yet.. :/
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.
- George Nasis
-
Topic Author
- Offline
- Elite Member
- Posts: 214
how can i check this?
thank you
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
use this snippet
<pre><?php echo var_dump($comment); ?></pre>
This will give you all of the object's elements which you can use.
Please Log in or Create an account to join the conversation.
- George Nasis
-
Topic Author
- Offline
- Elite Member
- Posts: 214
and i have this
object(stdClass)#989 (12) { ["id"]=> string(2) "49" ["itemID"]=> string(2) "62" ["userID"]=> string(3) "764" ["userName"]=> string(14) "giorgos nasis2" ["commentDate"]=> string(19) "2014-09-26 07:32:09" ["commentText"]=> string(26) "τι username βγάζει" ["commentEmail"]=> string(21) "This email address is being protected from spambots. You need JavaScript enabled to view it." ["commentURL"]=> string(0) "" ["published"]=> string(1) "1" ["userImage"]=> string(63) "www.proteino.gr/images/comprofiler/764_5422ebb4be78f.jpg" ["userLink"]=> string(44) "www.proteino.gr/cbprofile/userprofile" ["reportUserLink"]=> string(69) "/psyxagwgia/vivlio/mythistorima/comments/reportSpammer/764?format=raw" }
something that i already new from the table $comments in phpmyadmin..
what next?
thank you
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
You can use Joomla!'s getUser function to display the user's data.
docs.joomla.org/Accessing_the_current_user_object
Please Log in or Create an account to join the conversation.
- George Nasis
-
Topic Author
- Offline
- Elite Member
- Posts: 214
i did it.
i add $user = JFactory::getUser(); in the loop but know i have for every comment the same author..
it is so close to be done..any last advice?
thank you
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
eg:
$user = JFactory::getUser(99);
where 99 is your userID
Please Log in or Create an account to join the conversation.
- George Nasis
-
Topic Author
- Offline
- Elite Member
- Posts: 214
IT WORKED!
$user = JFactory::getUser($comment->userID);
thank you very very much!
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.
- George Nasis
-
Topic Author
- Offline
- Elite Member
- Posts: 214
i imagine that this line
<?php $user = JFactory::getUser($comment->userID); ?>
and this
<?php echo $user->username; ?>
was the answer of the very beginning of the forum.
Why didn`t you state that?i asked it because with too many responses you lost more time.
so two things i can imagine
1. it is my fault that from beginning i didn`t clear what i ask for
2. it is a policy of the administrators to search a little by themselves to understand how joomla,k2,php and tables are combining
:)
i repeat do not misunderstand me
really thank you anyway
best regards
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
I asked the var_dump because it is quite frankly impossible to remember what each object in K2 contains. I also do not want to give any wrong answers.
I can assist you in custom parts of your projects but your (by your I mean the user's) participation is needed. It is impossible to search the DB or perform template overrides for each single request.
This is the difference between getting help over a free forum and hiring a developer.
I personally try to help each member of the forum and avoid the "Go hire a developer" answers but users have to keep in their mind that you are not receiving help over a free product and you (again replace you with the user) have not hired a dev for their custom project.
I Hope I did not bore you with my rant.
Please Log in or Create an account to join the conversation.
- George Nasis
-
Topic Author
- Offline
- Elite Member
- Posts: 214
I understand you 100% and we all really thank you for your effort and for your contribution here.
How can somenoe hire you ? :)
best regards!
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Thank you for the request but at this point it would be unprofessional of me to offer commercial services from this forum.
However I can refer you to ideasencoded.gr/ which I can personally guarantee that she knows her way around K2. Trust me on this one :)
Please Log in or Create an account to join the conversation.
- George Nasis
-
Topic Author
- Offline
- Elite Member
- Posts: 214
thanx once again Krikor!
best regards!
Please Log in or Create an account to join the conversation.
- Bart Coenen
-
- Visitor
To me however it is not yet clear what to do to get this result. Can someone describe to me which lines in which file I have to alter?
Please Log in or Create an account to join the conversation.