The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

How can i get an automatic form for the editor

View previous topic View next topic Go down

Solved How can i get an automatic form for the editor

Post by vaccam on March 6th 2014, 3:01 pm

So my question is how can i get my topic to be like this? Because i really need that.

'


Thank you

Vaccam

Topic title changed

vaccam
Forumember

Posts : 371
Reputation : 14
Language : Norwegian
Location : Norway

http://www.revengelesspk.com/

Back to top Go down

Solved Re: How can i get an automatic form for the editor

Post by Ange Tuteur on March 6th 2014, 4:42 pm

Hello vaccam,

This is done with javascript to insert text into the editor when creating a topic in a specific forum.

Administration Panel > Modules > Javascript codes management > create a new script

Title : what you wish
Placement : in all the pages
Paste the code below and save :
Code:
$(function() {
  if (document.location.href.indexOf('/post?f=1&mode=newtopic') > -1) {
  $('#text_editor_textarea').val('[b]Field 1[/b]:\n[b]Field 2[/b]:\n[b]Field 3[/b]:');
  }
});

What you need to change :
In the condition of the if statement is the following
Code:
document.location.href.indexOf('/post?f=1&mode=newtopic') > -1)

You must change f=1 to the ID of the forum you want this to work in.

For example, if I wanted to add a form when users create a topic in this forum
http://generaltesting.forumotion.com/f2-test-2

I would need to change the forum ID to :
Code:
[code]document.location.href.indexOf('/post?f=2&mode=newtopic') > -1)[/code]

Since the forum ID is f2. You can see this ID from your address bar.

Lastly you need to edit/add to the form :
Code:
[b]Field 1[/b]:\n[b]Field 2[/b]:\n[b]Field 3[/b]:

To add a line break write : \n
If you're using single quotes write : \'

You must use the escape character when writing single quotes inside single quotes as it will act as if the string has ended.

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2684
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: How can i get an automatic form for the editor

Post by vaccam on March 6th 2014, 4:53 pm

It didnt work, here is the code i used.

Code:
$(function() {
    if (document.location.href.indexOf('post?f=21&mode=newtopic') > -21) {
      $('#text_editor_textarea').val('[b]In game name RevengelesPk - [/b]:\n[b]In game name Runescape - [/b]:\n[b]Item you want to purchase -[/b]'[b]Email -[b]');
    }
});

vaccam
Forumember

Posts : 371
Reputation : 14
Language : Norwegian
Location : Norway

http://www.revengelesspk.com/

Back to top Go down

Solved Re: How can i get an automatic form for the editor

Post by Ange Tuteur on March 6th 2014, 4:56 pm

Take a look back on the example. Wink

Here is the corrected code :
Code:
$(function() {
  if (document.location.href.indexOf('post?f=21&mode=newtopic') > -1) {
  $('#text_editor_textarea').val('[b]In game name RevengelesPk - [/b]:\n[b]In game name Runescape - [/b]:\n[b]Item you want to purchase -[/b]\n[b]Email -[b]');
  }
});

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2684
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: How can i get an automatic form for the editor

Post by vaccam on March 6th 2014, 4:59 pm

It worked, thank you so much !

vaccam
Forumember

Posts : 371
Reputation : 14
Language : Norwegian
Location : Norway

http://www.revengelesspk.com/

Back to top Go down

Solved Re: How can i get an automatic form for the editor

Post by Ange Tuteur on March 6th 2014, 5:15 pm

You're welcome I love you

Topic solved and archived

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2684
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

View previous topic View next topic Back to top


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