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.

Embedded comment form not displaying; permissions have been set in CP. What's wrong?

July 31, 2009 5:39pm

Subscribe [1]
  • #1 / Jul 31, 2009 5:39pm

    KomodoDave

    39 posts

    Hi guys,

    I have a weblog displayed on my main page; the code is as follows:

    {exp:weblog:entries status="Unanswered|Answered" weblog="Qs" limit="6" orderby="date" sort="desc"}
    <div class="Q" id="Q{entry_id}">
    /fonebox/webroot/images/uploads/{status}.jpg
    <span>{Question}</span><br>
    <span class="Q_date">{entry_date format='%M %d, %Y'}  -  {entry_date format='%g:%i'}  -  By {username}</span><br>
    <span class="Q_tags">Tags:</span><br>
    <span class="Q_actions">
        <span>Respond</span>
        <span>-</span>
        <a href="http://">Track</a>
        <span>-</span>
        <a href="http://">Share</a>
    </span><br>
    <div class="A" id="A{entry_id}">{embed="fonebox/AnswerForm" fb_weblog="Qs" fb_entry_id="{entry_id}"}</div>
    </div>
    <br><br> {!-- This line is used as a cutting point by Scripts, so don't modify it.
                         Also, don't use two consecutive <br> tags anywhere else in this template. --}
    {/exp:weblog:entries}

    As you can see, the weblog name is ‘Qs’ (short for “Questions”).

    I wish to display a comment entry form alongside each weblog entry. Thus I pass variables ‘fb_weblog’ (the weblog name) and ‘fb_entry_id’ (the weblog entry id) to an embedded template containing the comment entry form. Here is that template:

    {exp:comment:form weblog="{embed:fb_weblog}" entry_id="{embed:fb_entry_id}" preview="fonebox/AnswerPreview"}
    <input type="text" name="name" value="{name}" size="50"/>
    <input type="text" name="email" value="{email}" size="50"/>
    <input type="text" name="location" value="{location}" size="50"/>
    <input type="text" name="url" value="{url}" size="50"/>
    
    <textarea name="comment" cols="70" rows="10">{comment}</textarea></p>
    
    <input type="checkbox" name="save_info" value="yes" {save_info} /> Remember my personal information
    
    <input type="checkbox" name="notify_me" value="yes" {notify_me} /> Notify me of follow-up comments?
    
    {if captcha}
    
    Please enter the word you see in the image below:
    
    {captcha}
    
    <input type="text" name="captcha" value="{captcha_word}" maxlength="20" /></p>
    
    {/if}
    
    <input type="submit" name="submit" value="Submit" />
    <input type="submit" name="preview" value="Preview" />
    
    {/exp:comment:form}

    The code in this embedded template is, for now, the example provided in the documentation pages. I have merely added my passed variables as parameters ‘{weblog}’ and ‘{entry_id}’ to the template.

    ..Yet nothing displays. I have allowed the relevant member groups to view comments by author authors. I have allowed comments to be posted in the weblog Questions. There is no syntactical error that I can see. What am I doing wrong? I’ve read that you should have an entry id in the URL, in the form /path/to/entry_id - this is the one thing I’m not doing. However, given that I pass the entry id to the comment submission form template (via my ‘fb_entry_id’) I assume this isn’t required?

    I’d be very grateful for any assistance, this has me stumped!

    Best,

    Dave

  • #2 / Jul 31, 2009 11:11pm

    KomodoDave

    39 posts

    I’ve trawled the forums looking for an answer, no joy. I haven’t found any additional settings in CP regarding security that might be the issue, so I’m struggling to think what’s going wrong. That makes me a sad panda :(

    I ran some tests - the variables I pass (fb_weblog and fb_entry_id) are appearing in the template fine, as long as they’re outside the comment form tags.

    When I test the comment form explicitly like:

    {exp:comment:form weblog="Qs" entry_id="59"}
    ...
    {/exp:comment:form}

    ..then it still doesn’t display anything, even when I’m a Super User. I can’t figure out what setting I’m missing. I definitely have comment posting allowed in

    CP Home ›  Admin ›  Weblog Administration ›  Weblog Management ›  Edit Preferences > Comment Posting Preferences

    Do you know what else I should be doing?

  • #3 / Aug 02, 2009 8:39pm

    KomodoDave

    39 posts

    I’ve gleaned that the ‘url_title’ is required as well as the preview parameter - I provide both of these via parameters in my {exp:comment:form} tag. My site is AJAX’d, so the URL doesn’t change, hence using the parameters. Still nothing displays. I have an ‘allow_comments’ hidden variable set in my SAEF with value ‘y’, and as detailed above I’ve enabled comments for the weblog via the CP, and allowed the users to post comments.

    I’m almost tearing my hair out over this. I’ll be so grateful if you can help me, it’s holding development up considerably, much to my dismay!

  • #4 / Aug 02, 2009 9:36pm

    KomodoDave

    39 posts

    Ok, I’ve just spent 45 mins replying to help others out, even writing a simple plugin for one guy. I totally deserve help now. *awaits karmic balance*

  • #5 / Aug 02, 2009 10:22pm

    Lisa Wess

    20502 posts

    Dave, just as a test, can you create a comment form and visit it with a standard comment URL and see if that works? Let’s work out if it’s your setup or something else going on.

  • #6 / Aug 02, 2009 10:30pm

    KomodoDave

    39 posts

    Dave, just as a test, can you create a comment form and visit it with a standard comment URL and see if that works? Let’s work out if it’s your setup or something else going on.

    Sure thing Lisa - let me update you as to the actual situation I want to use the form in.

    Basically I have a very AJAX’d site, and thus far have managed to handle everything via AJAX just fine. I have an SAEF on the lone page you initially load (i.e. the homepage). I’ve successfully inserted other SAEFs onto that page too, and caught submit events with Javascript to do my own submission via AJAX instead.

    Anyway, when listing weblog entries I’d just like the comments to show below each specific entry. I assumed from the docs I could do this successfully if I just passed the weblog, entry_id, preview and url_title parameters, but it doesn’t want to work. I’ve said some of this above, I just wanted to make everything as clear as possible. I did indeed try the example I’ve posted above too, and made sure my browser wasn’t caching anything, and it wouldn’t work.

    I’ll paste the docs example for the comment submission form into a new template now. Two questions for you:

    i. What does a standard comment form URL look like (I believe it’s like this? ‘http://www.mysite.com/comment_template/63’)

    ii. Will the form display if the ‘preview’ parameter is not set or excluded? I’m not sure my preview form is correct, you see, and don’t want to complicate issues by having that cause the submission form to fail (if it’s possible).

    Thanks 😊

  • #7 / Aug 02, 2009 10:38pm

    Lisa Wess

    20502 posts

    A standard URL looks like:

    example.com/index.php/template_group/template_name/URL_title

    Or Entry ID in place of URL Title.

    See Understanding EE URLs and The Importance of Semantics.  Both things you need to understand before you embark on this type of manipulation.

    For now just set a fake preview URL, it won’t check if it’s valid, but it is required.

  • #8 / Aug 02, 2009 10:46pm

    KomodoDave

    39 posts

    I haven’t seen the semantics page before, many thanks for the links.

    I created a template ‘qtest’ in my ‘fonebox’ template group. I’ve checked in Edit, there is an entry in weblog ‘Questions” - short name ‘Qs’ - with entry id 64. Nothing displays when visiting:

    <a href="http://localhost/fonebox/webroot/index.php/fonebox/qtest/64">http://localhost/fonebox/webroot/index.php/fonebox/qtest/64</a>

    I clicked ‘View Rendered Template’ then appended ‘/64’ so there’s no issue with the URL.

    The new template ‘qtest’ simply contains the docs example, I copy and paste my template here:

    {exp:comment:form weblog="Qs" preview="weblog/preview"}
    
    {if logged_out}
    
    Name: <input type="text" name="name" value="{name}" size="50" /></p>
    
    Email: <input type="text" name="email" value="{email}" size="50" /></p>
    
    Location: <input type="text" name="location" value="{location}" size="50" /></p>
    
    URL: <input type="text" name="url" value="{url}" size="50" /></p>
    
    {/if}
    
    <textarea name="comment" cols="70" rows="10">{comment}</textarea></p>
    
    <input type="checkbox" name="save_info" value="yes" {save_info} /> Remember my personal information
    
    <input type="checkbox" name="notify_me" value="yes" {notify_me} /> Notify me of follow-up comments?
    
    {if captcha}
    
    Please enter the word you see in the image below:
    
    {captcha}
    
    <input type="text" name="captcha" value="{captcha_word}" maxlength="20" /></p>
    
    {/if}
    
    <input type="submit" name="submit" value="Submit" />
    <input type="submit" name="preview" value="Preview" />
    
    {/exp:comment:form}

    My entry form code, by the way, is this:

    {exp:weblog:entry_form weblog="Qs" return="fonebox/index" use_live_url="no"}
    {custom_fields}
    <input type="hidden" name="allow_comments" value="y"/>
    <input type="hidden" name="title" value="Q"/>
    <input type="hidden" name="status" value="Pending"/>
    <textarea dir="{text_direction}" id="{field_label}" name="{field_name}" rows="5" cols="100"></textarea>
    <input type="submit" id="Q_submit" name="submit" value=""/>
    {/custom_fields}
    {/exp:weblog:entry_form}
    <span>0 / 500</span>

    I hope there’s no issue with submitting ‘allow_comments’ in a hidden tag like that, I doubt there is..

    Thank you.

  • #9 / Aug 02, 2009 10:52pm

    Lisa Wess

    20502 posts

    If you make an entry via the control panel and then visit your test template, does the form show up?  Let’s also make sure the entry itself shows up:

    {exp:weblog:entries limit="1"}
    {title}
    
    {/exp:weblog:entries}

    What shows up then?

  • #10 / Aug 02, 2009 11:00pm

    KomodoDave

    39 posts

    Well, you’ve solved it for me 😊

    I made an entry via CP, checked the ‘Allow comments’ option was checked, then I had an inkling.. All entries to my Questions weblog are initially status ‘Pending’, and await moderation via a particular template. I replicate necessary values there, so it still looks as though the original author created the post, at the original time, even after moderation. BUT - I hadn’t even included, let alone replicated the ‘allow_comments’ hidden field, so it was being interpreted as an ‘n’ value.

    Thank you _so_ much for helping me, Lisa, I’m extremely happy and will now sleep very well! Enjoy your eve 😊

  • #11 / Aug 02, 2009 11:03pm

    Lisa Wess

    20502 posts

    Well, I didn’t do anything, but happy to help. =)

  • #12 / Aug 02, 2009 11:05pm

    KomodoDave

    39 posts

    Well, I didn’t do anything, but happy to help. =)

    lol, it’s your proactiveness and willingness to help that I praise - if you hadn’t made the effort to post a reply, I wouldn’t have taken my time to explain everything clearly, and wouldn’t have had a realisation. So thanks! 😊

  • #13 / Aug 02, 2009 11:06pm

    KomodoDave

    39 posts

    Well, I didn’t do anything, but happy to help. =)

    Hah, it’s your proactiveness and willingness to help that I praise - if you hadn’t made the effort to post a reply, I wouldn’t have taken my time to explain everything clearly, and wouldn’t have had a realisation. So thanks! 😊

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

ExpressionEngine News!

#eecms, #events, #releases