The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Need help with a code issue sent through Private Messages.

2 posters

Go down

Solved Need help with a code issue sent through Private Messages.

Post by RazielBach October 10th 2014, 4:22 am

Hey there, 

I have a question that I will detail in this post. The post might be a little lengthy because I'm going to explain everything I've tried so far. 

So what I'm trying to accomplish is to have a post available in a received private message, kind of like a quick reply box, or a normal post box. The purpose of this is to send a message (in the case of the PM a persons name) to a certain forum thread. 

The steps I took, involved me using the quick reply code directly from the forum, this is the code I used:

Code:
<form action="/post" method="post" name="post" id="quick_reply"><div id="textarea_content" style="width: 50%; clear: both; margin-left: auto; margin-right: auto; text-align: center;"><textarea id="text_editor_textarea" name="message"></textarea></div><div style="text-align:center; margin-top:20px;"><input type="hidden" name="attach_sig" value="1" /><input type="hidden" name="mode" value="reply" /><!-- <input type="hidden" name="sid" value="" /> --><input type="hidden" name="tid" value="bc5eb33b47750c241c5d6b364685a704" /><input type="hidden" name="t" value="110" /><input type="hidden" name="lt" value="255" /><input type="hidden" name="notify" value="1" /><script type="text/javascript">smilieoptions = {};</script><input type="submit" name="preview" class="button2" value="Preview" />&nbsp;<input type="submit" name="post" class="button2" value="Send" /></div><input type="hidden" name="auth[]" value="fb1feb76c1f9bcb0fb5fd380495b01d0" /><input type="hidden" name="auth[]" value="a1f66ddee3eda9ef5d8537a7a17a3952" /></form>

That code was copied directly from the forum. Sending that via a PM gave me a type of result I wanted. It looked perfect in the PM, and I was able to put a message, however, when I would click send, it would open up the thread and say there was an error, and make me have to submit the message through that. 

What I'm attempting to do is have it post directly from the PM without it having to redirect the member. So, I searched these forums to see if anyone else had a issue similar to mine, and I found one. I saw Ange Tuteur help another person with this issue, and I tried the code that she gave him, here is the code:

Code:
<form enctype="multipart/form-data" name="post" method="post" action="/post">
  <textarea id="text_editor_textarea" name="message"></textarea> <!-- Textarea -->
  <div id="authData" style="display:none;"></div> <!-- Auth data for permissions -->
  <script type="text/javascript">jQuery('#authData').load('/t110- input[name="auth[]"]');</script>
  <input name="mode" value="reply" type="hidden"/> <!-- Post mode -->
  <input name="t" value="110" type="hidden"/> <!-- Topic ID -->
  <input class="button1" name="post" value="Send" tabindex="6" accesskey="s" type="submit"/> <!-- Submit button -->
</form>

So I put that in the message, and everything worked perfectly, except it did not use this line

Code:
jQuery('#authData').load('/t110- input[name="auth[]"]');

So when you pressed send, it gave an error and brought you to a different page and wouldn't let you post, unlike the very first error. So I decided to go about it differently. I put this in a HTML page and made it so it wouldn't use my forum header and footer. So it was just the blank page and the text box; which, by the way, worked perfectly on that page. 

Seeing it worked like that, I decided to try a different route. I tried to use an iframe to display the message within a pm, so my overall code looked like:

Code:
<iframe style="width: 200px; height: 240px;" scrolling="no" frameborder="0" src="http://eriviyn.forumotion.com/h4-test"></iframe>


This worked perfectly, it gave me the exact visual result I wanted, I'm not sure if I can post a full picture, so I'll post it in a spoiler so it doesn't disturb the topic:

Picture:

However, it gave me the same issue I had initially from just copying the code from a quick reply box. It would submit the message, give an error and then bring me to an actual reply window to hit send there. 

I'm stumped as to what to do next to get it to work, if it is even possible. Any help would be greatly appreciated.

Edit: My forum address is http://eriviyn.forumotion.com
avatar
RazielBach
Forumember

Posts : 25
Reputation : 1
Language : English

http://eriviyn.forumotion.com

Back to top Go down

Solved Re: Need help with a code issue sent through Private Messages.

Post by Ange Tuteur October 10th 2014, 4:34 am

Hello RazielBach,

Is this to sent a private message to the founder ?
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Need help with a code issue sent through Private Messages.

Post by RazielBach October 10th 2014, 4:34 am

Nope, this is a private message that I (the founder) will be sending to every member on the forum at a certain time.
avatar
RazielBach
Forumember

Posts : 25
Reputation : 1
Language : English

http://eriviyn.forumotion.com

Back to top Go down

Solved Re: Need help with a code issue sent through Private Messages.

Post by Ange Tuteur October 10th 2014, 4:37 am

Where does the form post, does it post to specific topic ? If so could you provide the link to that topic ?

Thanks.
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Need help with a code issue sent through Private Messages.

Post by RazielBach October 10th 2014, 4:39 am

http://eriviyn.forumotion.com/t110-posts-go-here-for-character-names

That is where it is supposed to go. I have been moving that topic around a bit now since the codes I tried didn't work, although since it is topic based I don't think it matters what subsection it goes into matters. 

Nonetheless, when I initially tried this code, it was never moved.
avatar
RazielBach
Forumember

Posts : 25
Reputation : 1
Language : English

http://eriviyn.forumotion.com

Back to top Go down

Solved Re: Need help with a code issue sent through Private Messages.

Post by Ange Tuteur October 10th 2014, 4:42 am

See how this works :
Code:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<form enctype="multipart/form-data" name="post" method="post" action="/post">
  <textarea id="text_editor_textarea" name="message"></textarea> <!-- Textarea -->
  <div id="authData" style="display:none;"></div> <!-- Auth data for permissions -->
  <script type="text/javascript">jQuery('#authData').load('/t110- input[name="auth[]"]');</script>
  <input name="mode" value="reply" type="hidden"/> <!-- Post mode -->
  <input name="t" value="110" type="hidden"/> <!-- Topic ID -->
  <input class="button1" name="post" value="Send" tabindex="6" accesskey="s" type="submit"/> <!-- Submit button -->
</form>
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Need help with a code issue sent through Private Messages.

Post by RazielBach October 10th 2014, 4:47 am

So I tried that two different ways

The first way was just copying and pasting the code right into a PM, which sent the box and the send message, but did not register the:

Code:
jQuery('#authData').load('/t110- input[name="auth[]"]')

The second way I tried was by imbedding it, which worked perfectly and then redirected it to that page (as expected, since that happens after a post is made).

I have another question now, is it possible to set that up so it doesn't redirect, and when the form is submitted it posts to the topic and won't redirect the iframe?
avatar
RazielBach
Forumember

Posts : 25
Reputation : 1
Language : English

http://eriviyn.forumotion.com

Back to top Go down

Solved Re: Need help with a code issue sent through Private Messages.

Post by Ange Tuteur October 10th 2014, 5:16 am

Okay, try this :

Replace your HTML by :
Code:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<form enctype="multipart/form-data" name="post" method="post" action="/post" onsubmit="setData();">
  <textarea id="text_editor_textarea" name="message"></textarea> <!-- Textarea -->
  <div id="authData" style="display:none;"></div> <!-- Auth data for permissions -->
  <script type="text/javascript">jQuery('#authData').load('/t110- input[name="auth[]"]');</script>
  <input name="mode" value="reply" type="hidden"/> <!-- Post mode -->
  <input name="t" value="110" type="hidden"/> <!-- Topic ID -->
  <input class="button1" name="post" value="Send" tabindex="6" accesskey="s" type="submit"/> <!-- Submit button -->
</form>
<script type="text/javascript">function setData() { if (window.sessionStorage) sessionStorage.sentData = true }</script>

Then go to Administration Panel > Modules > Javascript codes management > Create a new script

Title : Data check
Placement : In all the pages
Paste the code below :
Code:
if (sessionStorage.sentData) {
  location.pathname = '/h1-';
  sessionStorage.removeItem('sentData');
}

sessionStorage.sentData is set when the form submits. If found the code above is executed. That means you'll be redirected to /h1- (first HTML page), replace this path with whatever you wish, even a new HTML page which displays success..
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Need help with a code issue sent through Private Messages.

Post by RazielBach October 10th 2014, 5:29 am

After the post is submitted, it pops up with You Can Return To The Index. I'm assuming with an iframe, this is good as I'm going to get. I don't believe (though I may be wrong) that the iframe can bring the main browser window to a certain page. 

I assume it'd work if the PM registered the 

Code:
jQuery('#authData').load('/t110- input[name="auth[]"]');

without the imbed. 

So I would say this is solved, unless you know of a way to make it so an imbedded page can bring the page it's imbedded to back to a different page. (worded kind of weird, sorry)
avatar
RazielBach
Forumember

Posts : 25
Reputation : 1
Language : English

http://eriviyn.forumotion.com

Back to top Go down

Solved Re: Need help with a code issue sent through Private Messages.

Post by Ange Tuteur October 10th 2014, 5:40 am

Unfortunately the frame can only modify its location. It cannot modify the window it is in. It's like another window/tab if that makes sense. Razz

You could make location.pathname = '/h1-'; be location.pathname = '/forum'; which returns the iframe to the forum. You could also create another HTML page with success texts and set its path as the redirect.
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Need help with a code issue sent through Private Messages.

Post by RazielBach October 10th 2014, 5:44 am

Yeah, it makes sense. And yep, I had the "/h1-" redirect it back to the forum, but like I said, it's the iframe. However, it seems like this is as good as it'll get. 

Thank you for the help! This is solved now.
avatar
RazielBach
Forumember

Posts : 25
Reputation : 1
Language : English

http://eriviyn.forumotion.com

Back to top Go down

Solved Re: Need help with a code issue sent through Private Messages.

Post by Ange Tuteur October 10th 2014, 5:45 am

You're welcome ^^

Topic archived

Have a great day. Smile
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum