I need to pass entry_id dynamically so I can embed the same comment form across several pages.
How would I go about doing that? Would it be by wrapping a channel:entries tag around my embed?
{embed="channels/messages-display" entry_id="{entry_id}”}
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
June 09, 2011 2:50pm
Subscribe [4]#1 / Jun 09, 2011 2:50pm
I need to pass entry_id dynamically so I can embed the same comment form across several pages.
How would I go about doing that? Would it be by wrapping a channel:entries tag around my embed?
{embed="channels/messages-display" entry_id="{entry_id}”}
#2 / Jun 10, 2011 4:02am
madebysplendid,
can you explain this in more context please?
Typically a comment form lives outside of the Channel Entries tag on a single entry page
If we knew the reasoning for you wanting to do this we may have more suggestions.
To answer your question, yes you can wrap the Channel Entries tag around the embed or in fact add it to your embed’s entry_id= parameter also.
#3 / Jun 10, 2011 4:48am
Hi John,
Sure — just trying to keep things as simple as possible 😊
I have a site with profile pages for contributors. Each profile page has a “leave a message” form, which is basically comments on a channel named “bloggers”.
My client has asked me to AJAXify the comment form, so I went off and found a plugin (AJAX Babble), but it’s documentation only accounts for a single hard-coded entry_ID (which works fine for that entry — see existing code below).
So — what I need is to be able to populate that entry_ID dynamically, according to the profile page being displayed.
Does that make sense?
Here’s the main template:
<div id="comments_container">
{embed='channels/messages-display' entry_id='2'}
</div>
{exp:ajax_babble:script
form_id='comment_form'
entry_id='2'
comments_template_url='{homepage}/channels/messages-display/'
comments_container_id='comments_container'
submit_button_id='comments_submit_button'
}
<a class="leave-message">Leave a message</a>
<div id="comment-form-div">
{exp:comment:form}
{if logged_out}
<label for="name">Name:</label> <input type="text" name="name" value="{name}" size="50" /><br >
<label for="email">Email:</label> <input type="text" name="email" value="{email}" size="50" /><br >
<label for="location">Location:</label> <input type="text" name="location" value="{location}" size="50" /><br >
<label for="url">URL:</label> <input type="text" name="url" value="{url}" size="50" /><br >
{/if}
<label for="comment">Comment:</label>
<textarea name="comment" cols="70" rows="10">{comment}</textarea></p>
{if captcha}
<label for="captcha">Please enter the word you see in the image below:</label>
{captcha}
<input type="text" name="captcha" value="{captcha_word}" maxlength="20" /></p>
{/if}
<input id="comments_submit_button" type="submit" name="submit" value="Submit Comment" /></p>
{/exp:comment:form}
</div></div>And here’s the embedded template to show the comments:
{exp:ajax_babble:comments entry_id="{embed:entry_id}" parse="inward"}
{exp:comment:entries channel='bloggers' orderby='date' sort='desc' limit='5'}
<div class="comment">{comment}
<cite>By {name} on {comment_date format="%d-%m-%Y"}</cite></div>
{/exp:comment:entries}
{/exp:ajax_babble:comments}#4 / Jun 10, 2011 5:15am
madebysplendid,
Thanks for explaining it. Does either method work for you from your original question?
#5 / Jun 10, 2011 5:28am
Well, I tried the code below and it seems to disable the submit button:
<div id="comments_container">
{exp:channel:entries channel='bloggers'}
{embed='channels/messages-display' entry_id='{entry_id}'}
{/exp:channel:entries}
</div>
{exp:channel:entries channel='bloggers'}
{exp:ajax_babble:script
form_id='comment_form'
entry_id='{entry_id}'
comments_template_url='{homepage}/channels/messages-display/'
comments_container_id='comments_container'
submit_button_id='comments_submit_button'
}
{/exp:channel:entries}#6 / Jun 11, 2011 3:10pm
Hi madebyspendid,
I’m afraid I’ve no experience of this addon but if you use the Safari/Chrome Inspector or Firebug are you seeing any Javascript errors? You may want to post in our Community Help forum to see if anyone else has successfully integrated this addon in a similar way.
Cheers
Greg
#7 / Jun 13, 2011 9:04am
Hi Greg,
Isn’t this (entry_ID) EE support rather than plugin support that I’m looking for help with?
#8 / Jun 14, 2011 3:15pm
Hi madebyspendid,
Can you clarify what you mean by the submit button being disabled? That sounds like an issue with the add-on or AJAX functionality.