Keyword

[SOLVED] display comment author username not name

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
3 years 9 months ago #132315 by George Nasis
George Nasis created the topic: [SOLVED] display comment author username not name
hallo there!

i notice that in comments, what is displayed is the commenter`s name and not username. although in item.php
there is
$comment->userName
i saw in the phpmyadmin table that the column userName has valued the name of the user and not the username. The author of the item is displayed properbly by this
$this->item->author->username
.

is there any way to apply this on the comments?

thank you very much

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

More
3 years 9 months ago #132316 by Krikor
Krikor replied the 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.

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

---
JoomlaWorks
www.joomlaworks.net/

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

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
3 years 9 months ago - 3 years 9 months ago #132317 by George Nasis
George Nasis replied the 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
$comment->userName
just as the item.php file


thank you

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

  • Bart Coenen
  • Bart Coenen's Avatar
  • Visitor
3 years 9 months ago #132318 by Bart Coenen
Bart Coenen replied the 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
3 years 9 months ago - 3 years 9 months ago #132319 by George Nasis
George Nasis replied the topic: Re: display comment author username not name
hi,

nothing yet.. :/

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

More
3 years 9 months ago #132320 by Krikor
Krikor replied the topic: Re: display comment author username not name
what does the var_dump of $comment print?

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

---
JoomlaWorks
www.joomlaworks.net/

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

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
3 years 9 months ago #132321 by George Nasis
George Nasis replied the 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.

More
3 years 9 months ago #132322 by Krikor
Krikor replied the 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.

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

---
JoomlaWorks
www.joomlaworks.net/

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

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
3 years 9 months ago #132323 by George Nasis
George Nasis replied the 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.

More
3 years 9 months ago #132324 by Krikor
Krikor replied the 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

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

---
JoomlaWorks
www.joomlaworks.net/

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

Moderators: william white