Username in comments
Posted: 01 April 2008 11:14 AM   [ Ignore ]  
Grad Student
Rank
Total Posts:  43
Joined  03-04-2005

Hello, what about a username variable in comments?
To know what I mean, please watch
http://expressionengine.com/forums/viewreply/365460/
thanks you )

Profile
 
 
Posted: 01 April 2008 12:03 PM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  30
Joined  02-24-2008

Doesn’t {author} solve this? Also, check this variable list.

*** EDIT ***

Ignore me. The screenshot didn’t load on the last page so I missed what you meant. Sorry.

Profile
 
 
Posted: 01 April 2008 12:41 PM   [ Ignore ]   [ # 2 ]  
Grad Student
Rank
Total Posts:  43
Joined  03-04-2005
Deviance - 01 April 2008 12:03 PM

Doesn’t {author} solve this? Also, check this variable list.

In this variables no “{username}

Image Attachments
username.jpg
Click thumbnail to see full-size image
Profile
 
 
Posted: 01 April 2008 01:21 PM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  30
Joined  02-24-2008

I understand what you mean now and agree that would be useful in some situations. I can’t believe it isn’t already available.

Qrat, if you want to know why it’s because the users screen name is stored in the same table as the comments. This gets pulled out as the {author} instead of data being made available from the members table.

I guess my reason to have this feature is becuase the user’s screen name at the time of commenting will be permenantly attached to the comment. If a user changes their screen name their old one will still show for the comments made using it.

A permenant fix would be to modify the comment module with an SQL JOIN for the members table but I don’t need this feature right now so hopefully this feature will get implimented by the EE team.

Profile
 
 
Posted: 05 June 2008 01:11 AM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  29
Joined  07-17-2005

I would like this feature as well so I can link to a member profile (i’m using solspace’s user module) using the the username in the url rather than the member id.

Profile
 
 
Posted: 05 June 2008 03:20 AM   [ Ignore ]   [ # 5 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  247
Joined  04-12-2008

Hm, you could pack this into a plugin, but why not just using the query module?

{exp:comment:entries weblog="your_weblog" limit="25"}
{comment}

{exp
:query sql="SELECT m.username FROM exp_comments c INNER JOIN exp_members m ON c.author_id = m.member_id WHERE c.comment_id = {comment_id}"}
<p>Username: {username}</p>
{/exp:query}

{
/exp:comment:entries}

Let me know if this works, worked for me on my test site.

Selecting more, you can fetch all the data from the members table.

 Signature 

Designchuchi | Twitter

URL Field Extension
Required Category Extension
DC FreeForm GeoIP Extension

Profile
 
 
Posted: 05 June 2008 03:27 AM   [ Ignore ]   [ # 6 ]  
Summer Student
Total Posts:  29
Joined  07-17-2005

You can just do (I think)...

{exp:member:custom_profile_data member_id="{author_id}"}{username}{/exp:member:custom_profile_data}

The point is both approaches generate needless database queries. You could just do the whole retrieval of the comments using the query module joining the member data but it would be preferable for this facility to be built in. Hence the support of the feature request.

Thanks for the suggestion though.

Profile
 
 
Posted: 05 June 2008 03:30 AM   [ Ignore ]   [ # 7 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  247
Joined  04-12-2008
mreeves - 05 June 2008 03:27 AM

You can just do (I think)...

{exp:member:custom_profile_data member_id="{author_id}"}{username}{/exp:member:custom_profile_data}

The point is both approaches generate needless database queries. You could just do the whole retrieval of the comments using the query module joining the member data but it would be preferable for this facility to be built in. Hence the support of the feature request.

Thanks for the suggestion though.

Yes, this should work too, but here you’r invoking the entire member field module and selecting all the fields whereas with the query module, you can just select the “username” field. Nevertheless, you have to do one query for each comment being displayed.

 Signature 

Designchuchi | Twitter

URL Field Extension
Required Category Extension
DC FreeForm GeoIP Extension

Profile
 
 
Posted: 05 June 2008 03:36 AM   [ Ignore ]   [ # 8 ]  
Grad Student
Rank
Total Posts:  43
Joined  03-04-2005
mreeves - 05 June 2008 03:27 AM

You can just do (I think)...

{exp:member:custom_profile_data member_id="{author_id}"}{username}{/exp:member:custom_profile_data}

The point is both approaches generate needless database queries. You could just do the whole retrieval of the comments using the query module joining the member data but it would be preferable for this facility to be built in. Hence the support of the feature request.

Thanks for the suggestion though.

It required more queries than peschehimself’s way I think

Profile
 
 
Posted: 05 June 2008 03:45 AM   [ Ignore ]   [ # 9 ]  
Summer Student
Total Posts:  29
Joined  07-17-2005

Fair comments. To improve further on above…

{exp:comment:entries weblog="your_weblog" limit="25"}
{comment}

{exp
:query sql="SELECT username FROM exp_members WHERE member_id = '{author_id}'"}{username}{/exp:query}

{
/exp:comment:entries}

Elimiates the need for the join.

Best regards
Martin

Profile
 
 
   
 
 
‹‹ Updating EE      {redirect} anywhere ››
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65102 Total Logged-in Users: 63
Total Topics: 82263 Total Anonymous Users: 31
Total Replies: 442115 Total Guests: 233
Total Posts: 524378    
Members ( View Memberlist )