MyBB Community Forums

Full Version: How to insert quoting post into a modal box
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey everyone.

I am using this tutorial to create a modal quote post. Allow me to elaborate; when the user clicks "reply to this post" (traditionally the quote/reply button), instead of taking them to newreply.php, it opens up a modal box, where the user can reply to the post. However, I require the content of the post they are quoting to be inserted into the text box automatically.

Here is the contents of my "postbit_quote" template, where I have included the code for the modal popup:
<a name="modal" rel="#respondModal" class="small blue-button" href="newreply.php?tid={$tid}&amp;pid={$post['pid']}">Reply to This Post</a>

<div id="respondModal" class="respondModalBox modalBox" style="width: 580px;">
<div class="modalContent respondModalContent">


<form method="post" action="newreply.php?tid={$tid}&amp;processed=1" name="quick_reply_form" id="quick_reply_form">
	<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
	<input type="hidden" name="subject" value="RE: {$thread['subject']}" />
	<input type="hidden" name="action" value="do_newreply" />
	<input type="hidden" name="posthash" value="{$posthash}" id="posthash" />
	<input type="hidden" name="quoted_ids" value="" id="quoted_ids" />
	<input type="hidden" name="lastpid" id="lastpid" value="{$last_pid}" />
	<input type="hidden" name="from_page" value="{$page}" />
	<input type="hidden" name="tid" value="{$tid}" />
	<input type="hidden" name="method" value="quickreply" />

	<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
		<thead>
			<tr>
				<td class="thead" colspan="2">
					<div class="expcolimage"><a rel="closeModal" href="#"><img style="vertical-align: middle;" src="{$theme['imgdir']}/close.png" /></a></div>
					<div><strong>{$lang->quick_reply}</strong></div>
				</td>
			</tr>
		</thead>
		<tbody style="{$collapsed['quickreply_e']}" id="quickreply_e">
			<tr>
				<td class="trow1">
					<div style="width: 99%; max-width: 99%;">
						<textarea style="width: 100%; padding: 4px; margin: 0;" rows="8" cols="80" name="message" id="message" tabindex="1"></textarea>
					</div>
					<div class="editor_control_bar" style="width: 95%; padding: 4px; margin-top: 3px; display: none;" id="quickreply_multiquote">
						<span class="smalltext">
							{$lang->quickreply_multiquote_selected} <a href="./newreply.php?tid={$tid}&amp;load_all_quotes=1" onclick="return Thread.loadMultiQuoted();">{$lang->quickreply_multiquote_now}</a> {$lang->or} <a href="javascript:Thread.clearMultiQuoted();">{$lang->quickreply_multiquote_deselect}</a>.
						</span>
					</div>
				</td>
			</tr>
			{$captcha}
			<tr>
				<td colspan="2" align="center" class="tfoot"><input type="submit" class="button" value="{$lang->post_reply}" tabindex="2" accesskey="s" id="quick_reply_submit" /> <input type="submit" class="button" name="previewpost" value="{$lang->preview_post}" tabindex="3" /></td>
			</tr>
		</tbody>
	</table>
</form>



</div>

</div>

This set up allows you to reply to the thread no problem, but I am unsure of how to get the quoted post to be inserted automatically. I have no idea what it entails or how difficult it is, but if it is a simple fix I would appreciate any help!

Whilst I'm here, another issue with the modal box I'm having is getting it to close once the submit button has been clicked. Currently, the reply is inserted to the thread, but the modal box remains open. Is anyone able to tell me how to close the modalbox once the submit button has been clicked?

Many thanks!
As for 2nd issue, I'd simply use something like this:
$("#quick_reply_submit").on("click", function(){
  $("#respondModal").hide(600);
});
I use something similar to this on leefish; it is just the showthread_quickreply wrapped in a hidden div and does not actually quote the entire post.

it does work with multiquote though.

unfortunately, this popup of mine is a prototype solution, not jQuery.
(2013-04-23, 05:40 PM)Destroy666 Wrote: [ -> ]As for 2nd issue, I'd simply use something like this:
$("#quick_reply_submit").on("click", function(){
  $("#respondModal").hide(600);
});

Thanks a lot, with a bit of tweaking it worked perfectly:

jQuery.noConflict()
jQuery("#quick_reply_submit").on("click", function(){
  jQuery("#mask").hide(600);
  jQuery("#respondModal").hide(600);
});

(2013-04-23, 06:07 PM)Leefish Wrote: [ -> ]I use something similar to this on leefish; it is just the showthread_quickreply wrapped in a hidden div and does not actually quote the entire post.

it does work with multiquote though.

unfortunately, this popup of mine is a prototype solution, not jQuery.

Thanks for the response. Still a bit confused though...were you offering a solution, an alternative, or just a relevant comment, I can't really tell :p
An alternative , but as it is a prototype solution then it will be dead when 1.8 comes out Big Grin
(2013-04-23, 07:20 PM)Leefish Wrote: [ -> ]An alternative , but as it is a prototype solution then it will be dead when 1.8 comes out Big Grin

Hmm, fair enough then. Do you know if what I am asking is possible without re-writing chunks of the code, or ideally without tampering with any php files?