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.

Comment Form Not Appearing

May 14, 2011 5:28pm

Subscribe [4]
  • #1 / May 14, 2011 5:28pm

    tylerjames

    10 posts

    Hey Everyone,

    So I’m in the process of developing my first Expression Engine website and I having issues with the comment form. My site is a blog site where users click the blog and see a sumarry of 3 entries per page. I want to let them add comments from that page as well as the individual post pages (where I have the form working). When I add the typical {exp:comment:form} tags, it’s not building the form. Anyone have some help with what I need to include in the tag to get it to build?

    here’s the website: http://tylerjamesphoto.com

    Thanks!

  • #2 / May 14, 2011 5:48pm

    Mark Bowen

    12637 posts

    Hi Tyler,

    Are you talking about the - http://www.tylerjamesportfolio.com/tylerjames/blog page?

    You want a comment form on that page?

    If so then that’s not the way the comment form is made to work as it usually needs to be on a single entry page in order for it to work as it (the form) needs certain information (either the url_title or entry_id) in order to be able to show the form. Don’t worry though it can be done but what you will need to do is pass in the comment form from a separate template as an embed and pass in the entry_id or url_title to the embedded template in order for it to get the correct information.

    Main Template

    {exp:channel:entries
        channel="blog"
        limit="10"
        dynamic="no"
        sort="asc"
        disable="member_data|pagination|categories"}
    
    {title}
    {embed="comment-form" entry_id="{entry_id}"}
    
    {/exp:channel:entries}

    Embedded comment-form template

    {exp:comment:form
    entry_id="{embed:entry_id}"
    channel="blog"
    preview="channel/preview"}
    
    …rest of comment form here…
    
    {/exp:comment:form}

    That should then enable it to work for you.

    Hope that helps a bit.

    Best wishes,

    Mark

  • #3 / May 15, 2011 3:32am

    tylerjames

    10 posts

    That’s exactly what I was looking for! Thank you so much Mark! I’ll give it a whirl tonight and see how it goes. You rock dude!

  • #4 / May 15, 2011 3:59am

    tylerjames

    10 posts

    Small issue. The form is working, but when I make a comment, it’s always adding it to the top post in the stack. So if I’m displaying posts 1,2 and 3 and comment on post 3, it’s getting added to post number 1. Everything else looks good though.

  • #5 / May 15, 2011 3:59am

    Sue Crocker

    26054 posts

    Thanks for the assist, Mark.

    tylerjames - let us know when you’ve had a change to test with Mark mentioned.

  • #6 / May 15, 2011 6:56am

    Mark Bowen

    12637 posts

    Small issue. The form is working, but when I make a comment, it’s always adding it to the top post in the stack. So if I’m displaying posts 1,2 and 3 and comment on post 3, it’s getting added to post number 1. Everything else looks good though.

    When you say the comment is being added to the top post can you show an example of what you are doing exactly?

    I just went to the blog page but can’t see the comment form or comment entries on there so I take it you are testing this on some test templates somewhere?

    At a guess though I would hazard that what is happening is the same sort of thing as with the comment form. Both it and the Comment Entries tags are meant to be used on single entry pages however as in the post above they can be used in the way you want but you need to pass them in as embeds. Therefore you would need to make another template which contains your Comment Entries tag and do the same thing as done before with the comment form tag :

    Main Template

    {exp:channel:entries
        channel="default_site"
        dynamic="no"
        sort="asc"
        disable="member_data|pagination|categories"}
    
    {title}
    {embed="comment-entries" entry_id="{entry_id}"}
    
    {/exp:channel:entries}

    Embedded Template - comment-entries

    {exp:comment:entries
    entry_id="{embed:entry_id}"
    dynamic="no"
    sort="asc" limit="20"}
    
    …rest of comment entries tag data…
    
    {/exp:comment:entries}

    The dynamic=“no” in the Comment Entries tag is very important here as even though it is an embedded template it will still ‘see’ what is in the URL and so this needs to be turned off in order for it to work correctly.

    Hope that helps a bit. If not then please do let us see where you are testing this so that we can get a better feel for exactly what it is that you’re trying to achieve.

    Best wishes,

    Mark

  • #7 / May 15, 2011 1:59pm

    Greg Salt

    3988 posts

    Hi tylerjames,

    Does Mark’s last post solve this issue for you?

    Cheers

    Greg

    @Mark, thanks very much for the help.

  • #8 / May 15, 2011 2:58pm

    tylerjames

    10 posts

    Hey Guys, I’m going to give it a test to see. I didn’t set dynamic=“no” so that was probably my issue 😊 As soon as I give it a shot I’ll let you know how it works! Thanks a bunch!!

  • #9 / May 15, 2011 3:00pm

    Greg Salt

    3988 posts

    Hi tylerjames,

    Okay. Let us know how you get on.

    Cheers

    Greg

  • #10 / May 15, 2011 3:13pm

    tylerjames

    10 posts

    Hey Guys, still no go. I left the code up so you can see what I’m trying to do. Basically if I comment on any post other than the top post, you’ll see the top post’s comments update and not the one clicked. Set the dynamic to no on both and it’s still not working.

  • #11 / May 16, 2011 10:25am

    Mark Bowen

    12637 posts

    Eek!! Every time I’ve been to the site I’ve never seen the comment button beneath each of the posts. When you said above you’d left the code up I thought I was going mad and missing a link somewhere! 😊

    I see the buttons now and I also see what your problem is. Each ‘Comment’ button is pointing to a comment-form ID which in itself is okay except that IDs on a page cannot have the exact same name or what will happen is that the page will only ever accept the first one.

    What you will need to do here is slightly change your code so that each button points to a different comment form such as #comment-form-32, #comment-form-33 where the 32 and 33 are the entry_id‘s for the entry.

    This way when you click the comment button it will bring up the correct form. What is happening is at the moment just the first comment form is being shown.

    Change the ID’s on the forms and on the comment buttons and it should all start to work as you need though.

    Hope that helps a bit.

    Best wishes,

    Mark

  • #12 / May 16, 2011 10:31am

    Mark Bowen

    12637 posts

    Oops yes meant to mention that I just posted a couple of test comments on the site so please do delete that one. I’m sure you’ll see it anyway but just thought I’d let you know.

    The first one went into the top post but the second I got to go into the Dana & Jamie post by editing the source code with Firebug so that the comment button anchor and the comment form ID had the same number in them.

    Best wishes,

    Mark

  • #13 / May 16, 2011 10:32am

    Kevin Smith

    4784 posts

    Hey tylerjames—

    It looks to me like it’s a problem with your Fancybox displaying the wrong comment form. When I look at your source code, I can see that each comment form is being rendered correctly by EE, but clicking on the Comment link in all three posts brings up the same form in your javascript modal, which is the first one. That’s why all your comments are being filed under the first post.

    Could you check into this and make sure the correct comment form is being show by Fancybox? You do have multiple elements with the ID “comment-form” on them, so Fancybox probably doesn’t know which one to select. This also isn’t valid HTML markup, so I would suggest adding the entry ID to the end of that ID tag (and in the <a> tag that references the comment-form element) so that each link/comment box elements are unique pairs.

    How does that work out for you?

    Kevin

  • #14 / May 16, 2011 11:03am

    Mark Bowen

    12637 posts

    Great minds think alike 😉

  • #15 / May 16, 2011 2:44pm

    tylerjames

    10 posts

    Thanks a ton guys! I’ll monkey around with the html and see where it gets me. At least I understand the problem now so I should be able to fix things. I really appreciate your help!!

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

ExpressionEngine News!

#eecms, #events, #releases