« One Page Web site–Does Your Business Really Need More?

Expression Engine- Posting User Comments Inside a Post on Your index.php Page

ee-tip.jpgHey, I am proud to say we have some pretty smart and talented people around here.

We have a client, that requested to have the last comment posted to a particular post, display on the index.php page inside that post. (Confused? I am.)

Hmmm… after exploring the webs, the internets, and the Expression Engine knowledge base we came up empty (see this thread). Not that others hadn’t asked and tried, but we found no solutions. Evidently, this is an “EE” no-no, showing comments is for post perma link pages only.

Well I have news, James, one of our smart/talented developers, formulated a solution.

{exp:query sql=&#8221;SELECT * FROM exp_comments WHERE entry_id IN ({entry_id}) ORDER BY comment_date DESC LIMIT 1&#8243;}</p> <p> <strong><a href="{profile_path=members/profile}">{name}</a> | {comment_date format=&#8217;%F %j, %Y&#8217;} at {comment_date format=&#8217;%h:%i %a&#8217;}: </strong><br /> <a href="{url_title_path=posts/{my_location}}#c_{comment_id}">{exp:word_limit total=&#8221;10&#8243;}{exp:html_strip}{comment}{/exp:html_strip}{/exp:word_limit}</a> </p> <p>{/exp:query}

This will allow you to show an excerpt of the last comment in a post on the index.php page. Great job, James!

Similar Posts:  How-to, Quick Tip, Web.
Comments Feed:  RSS 2.0
You can leave a response, or trackback from your own site.

One Response to “Expression Engine- Posting User Comments Inside a Post on Your index.php Page”

  1. Jim L Says:
    May 30th, 2008 at 8:15 am

    Wow! This is one of the best tips I’ve ever seen! This kid James must be some kind of programming genius. Whatever you’re paying him you should at least triple it!

Leave a Reply