Keyword

display comment author username not name

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
10 years 7 months ago #132315 by George Nasis
hallo there!

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
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 7 months ago #132316 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: display comment author username not name
The $this->item... will return information regarding this particular item not the comment.

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
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
10 years 7 months ago - 10 years 7 months ago #132317 by George Nasis
Replied by George Nasis on topic Re: display comment author username not name
hallo!

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
  • Bart Coenen's Avatar
  • Visitor
10 years 7 months ago #132318 by Bart Coenen
Replied by Bart Coenen on topic Re: display comment author username not name
Hi,

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
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
10 years 7 months ago - 10 years 7 months ago #132319 by George Nasis
Replied by George Nasis on topic Re: display comment author username not name
hi,

nothing yet.. :/

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 7 months ago #132320 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: display comment author username not name
what does the var_dump of $comment print?

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

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
10 years 7 months ago #132321 by George Nasis
Replied by George Nasis on topic Re: display comment author username not name
hallo krikor,

how can i check this?

thank you

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 7 months ago #132322 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: display comment author username not name
in the comments loop (item.php)

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
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
10 years 7 months ago #132323 by George Nasis
Replied by George Nasis on topic Re: display comment author username not name
ok i run it.
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
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 7 months ago #132324 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: display comment author username not name
Now you know the userID which is in this example 764.
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
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
10 years 7 months ago #132325 by George Nasis
Replied by George Nasis on topic Re: display comment author username not name
trully thank you for your respnse Krikor,

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
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 7 months ago #132326 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: display comment author username not name
You need to pass the userId agument like the example in the URL

eg:
$user = JFactory::getUser(99);

where 99 is your userID

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

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
10 years 7 months ago - 10 years 7 months ago #132327 by George Nasis
Replied by George Nasis on topic Re: display comment author username not name
PERFECT!!!
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
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 7 months ago #132328 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: display comment author username not name
You 're welcome George.

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

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
10 years 7 months ago #132329 by George Nasis
Replied by George Nasis on topic Re: display comment author username not name
really do not misunderstand me and i already apologized if that i will say is offending you

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
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 7 months ago #132330 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: display comment author username not name
You have to understand that we are here to help a really large number of people here every day.

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
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
10 years 7 months ago #132331 by George Nasis
Replied by George Nasis on topic Re: display comment author username not name
Absolutely you were not tiring. Your answer is really helpful and it was necessary.
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
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 7 months ago #132332 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: display comment author username not name
Thanks George I really appreciate this.

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
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
10 years 7 months ago #132333 by George Nasis
Replied by George Nasis on topic Re: display comment author username not name
nice to hear that!

thanx once again Krikor!

best regards!

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

  • Bart Coenen
  • Bart Coenen's Avatar
  • Visitor
10 years 7 months ago - 10 years 7 months ago #132334 by Bart Coenen
Nice that you found the solution (and a funny conversation :lol: ).

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.