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.

Problem with displaying comments for weblog entry

June 22, 2009 12:55pm

Subscribe [2]
  • #1 / Jun 22, 2009 12:55pm

    apfeiffer

    13 posts

    Greetings,

    I’m doing the production on a site for a client and they’ve designed one of the pages with the following set up: They want to show the most current entry from the selected weblog on the page along with it’s comments. I’m using this code to display the weblog entry, which seems to be working fine, when you access the page the latest entry from the “watch” weblog is displayed:

    {exp:weblog:entries weblog="watch" limit="1" disable="member_data|pagination|trackbacks|categories"}
    
    Newest entry from weblog is displayed here
    
    {/exp:weblog:entries}

    However, because I am not passing the name of an actual entry in the URL, the comments for that entry are not being displayed. Is there a way to solve this? I did some research and it seems to me if I can pull out the entry id of the weblog entry and feed it to the comment tag as a variable I can get them to sync up. I found this article in the Wiki and was wondering if this was the way to go:

    Using the entry id output from a weblog tag in another weblog tag

    If someone could let me know if I’m on the right track I would appreciate it.

    Thanks,

    Andy

  • #2 / Jun 22, 2009 1:14pm

    Mark Bowen

    12637 posts

    Hi Andy,

    I’ll try and lend a hand as it was me that wrote that WIKI post 😉

    What you will probably need to do here is two things. The first being you will definitely want to be using the dynamic=“off” parameter on your weblog tag above so that it doesn’t get any information from whatever URL you are on.

    {exp:weblog:entries weblog="default_site" limit="1" dynamic="off" disable="member_data|pagination|trackbacks|categories"}
    
    <h3>Most recent commented entry - {title}</h3>
    <p>{embed="site/latest-comment" entry_id="{entry_id}"}</p>
    
    <p>{/exp:weblog:entries}

    Next up noticed the embedded template which you will need here to be able to show the comment. The {entry_id} is passed in to the embedded template which contains our comment entries tag :

    Embedded Template (site/latest-comment)

    {exp:comment:entries sort="asc" limit="20" entry_id="{embed:entry_id}" dynamic="off"}
    
    {comment}
    
    By {name} on {comment_date format="%Y %m %d"}
    
    {/exp:comment:entries}

    The embedded template with the comment entries tag on it also contains the same dynamic=“off” parameter to ensure we only get what we need. It’s probably not needed as we are absolutely sending in the entry_id anyway but it doesn’t harm to put it there anyway just to make sure 😊

    Hopefully that should do what you need.

    Best wishes,

    Mark

  • #3 / Jun 22, 2009 3:42pm

    apfeiffer

    13 posts

    You sir, are a life saver. It worked perfectly. Many thanks for the assistance and the quick response. Hopefully one of these days I’ll get to the point where I know enough about EE to have answers for the forums instead of just questions.  😊

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

ExpressionEngine News!

#eecms, #events, #releases