ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Show Email Address in Comments

May 05, 2009 4:43am

Subscribe [3]
  • #1 / May 05, 2009 4:43am

    Frychiko

    79 posts

    Moderator’s note: Moved to Howto.

    Hi,

    I was wondering if it is possible to display an email address for each comment displayed under an weblog post.

    I run weekly giveaways and it is quite annoying having to find emails by SQL queries in the admin section of the control panel. Last time I checked the documentation there was no option to display the email address.

    cheers,
    Peter

  • #2 / May 05, 2009 5:06am

    Sean C. Smith

    3818 posts

    url or email is about the best you can do.

  • #3 / May 05, 2009 5:18am

    Frychiko

    79 posts

    I was afraid that was going to be the answer. Thanks Sean.

  • #4 / May 05, 2009 5:26am

    Sean C. Smith

    3818 posts

    You might be able to do it using the query module, but I wouldn’t know where to start.

  • #5 / May 05, 2009 6:12am

    Mark Bowen

    12637 posts

    It looks to me as though the e-mail and also the URL of the poster gets saved to the same exp_comments table so you should be able to make a fairly simple SQL query something like this :

    {exp:query sql="
    SELECT email, url FROM exp_comments WHERE comment_id = '{comment_id}'
    "}
    {if email != ""}
    {email}
    {if:elseif url !=""}
    {url}
    {/if}
    {/exp:query}

    That would get placed inside your {exp:comment:entries} tag. This should bring back the e-mail (if one was supplied) and if not it would bring back the url instead. Obviously you would need to place the html code around those variables to make them into valid e-mail or URL links but that should hopefully get you what you are looking for.

    Best wishes,

    Mark

  • #6 / May 05, 2009 6:29am

    Frychiko

    79 posts

    Oh wow! Thanks Mark. I will try that later tonight!

  • #7 / May 05, 2009 6:30am

    Mark Bowen

    12637 posts

    Oh wow! Thanks Mark. I will try that later tonight!

    No problem at all. I didn’t actually test it out yet but I’m pretty sure it will work as it is a nice simple query and I can see from looking at a site I have with comments on that they get stored to that table so should all work as advertised hopefully.

    Anyway let me know how it goes.

    Best wishes,

    Mark

  • #8 / May 11, 2009 9:44am

    Frychiko

    79 posts

    Hi Mark,

    Sorry for the late reply. Works like a charm! prob solved.

  • #9 / May 11, 2009 10:15am

    Mark Bowen

    12637 posts

    Hi Mark,

    Sorry for the late reply. Works like a charm! prob solved.

    Excellent news! 😊

    Glad it worked out for you.

    Best wishes,

    Mark

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases