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.

How can I add an automatic poll like here on the support forum?

2 posters

Go down

Solved How can I add an automatic poll like here on the support forum?

Post by Guest August 31st 2015, 3:00 pm

Hi, I'm having trouble adding an automatic poll to my forum. I'd like the auto poll to be activated for the suggestions



Forum Version: PHPBB3

Forum URL: http://theoriginals.4umotion.com/


Last edited by Ghost on October 4th 2015, 5:07 pm; edited 2 times in total
avatar
Guest
Guest


Back to top Go down

Solved Re: How can I add an automatic poll like here on the support forum?

Post by Ace 1 September 1st 2015, 3:06 am

You want it so the entire forum is polls? Or just regular topics (excluding sticky's, etc.)
Ace 1
Ace 1
Helper
Helper

Male Posts : 843
Reputation : 64
Language : English - French?
Location : Druid Hill Park

https://help.forumotion.com

Back to top Go down

Solved Re: How can I add an automatic poll like here on the support forum?

Post by Guest September 1st 2015, 3:21 am

Ace 1 wrote:You want it so the entire forum is polls? Or just regular topics (excluding sticky's, etc.)
regular topics.(excluding sticky's etc.)
avatar
Guest
Guest


Back to top Go down

Solved Re: How can I add an automatic poll like here on the support forum?

Post by Guest October 4th 2015, 3:41 pm

Bump
avatar
Guest
Guest


Back to top Go down

Solved Re: How can I add an automatic poll like here on the support forum?

Post by Ange Tuteur October 4th 2015, 4:16 pm

Hi @Ghost,

You can add this by going to Modules > JavaScript codes management > and create a new script

Placement : In all the pages
Code:
window.location.pathname == '/post' && $(function () {
  var lang = {
    info : 'The poll will be added automatically.',
    poll_question : 'Do you agree or disagree ?',
    poll_answers : 'Agree\nDisagree'
  };

  if (document.post && document.post.mode.value == 'newtopic' && document.post.f.value == 14) {
    $(document.post.poll_title).closest('fieldset').html('<strong>' + lang.info + '</strong><input type="hidden" name="poll_title" value="' + lang.poll_question + '" /><input type="hidden" name="poll_option_text" value="' + lang.poll_answers + '"><input type="hidden" name="poll_length" value="30" /><input type="hidden" name="poll_cancel_vote" value="1" />');
  }
});

The 14 in document.post.f.value == 14 is the id of the forum this will be applied to.

At the top of the script you can adjust the language settings and poll answers. Note that multiple answers should be separated by \n also known as a "newline" character.
Ange Tuteur
Ange Tuteur
Forumaster

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

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: How can I add an automatic poll like here on the support forum?

Post by Guest October 4th 2015, 4:29 pm

Thank you, @Ange Tuteur. Also for sub-forums, am I suppose to do the same?
avatar
Guest
Guest


Back to top Go down

Solved Re: How can I add an automatic poll like here on the support forum?

Post by Ange Tuteur October 4th 2015, 4:36 pm

If you're applying this to multiple forums then I'd suggest this approach :
Code:
window.location.pathname == '/post' && $(function () {
  var forums = [1, 2, 3, 14],

  lang = {
    info : 'The poll will be added automatically.',
    poll_question : 'Do you agree or disagree ?',
    poll_answers : 'Agree\nDisagree'
  },

  i = 0,
  j = forums.length,
  f;

  if (document.post && document.post.mode.value == 'newtopic') {
    f = document.post.f.value;
   
    for (; i < j; i++) {
      if (f == forums[i]) {
        $(document.post.poll_title).closest('fieldset').html('<strong>' + lang.info + '</strong><input type="hidden" name="poll_title" value="' + lang.poll_question + '" /><input type="hidden" name="poll_option_text" value="' + lang.poll_answers + '"><input type="hidden" name="poll_length" value="30" /><input type="hidden" name="poll_cancel_vote" value="1" />');
        break;
      }
    }
  }
});

At the top is an array called "forums", it contains multiple forum ids that the script should be applied to. Make sure to separate each id by a comma. Wink
Ange Tuteur
Ange Tuteur
Forumaster

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

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: How can I add an automatic poll like here on the support forum?

Post by Guest October 4th 2015, 5:07 pm

Okay, thanks.
topic solved
avatar
Guest
Guest


Back to top Go down

Solved Re: How can I add an automatic poll like here on the support forum?

Post by Ange Tuteur October 4th 2015, 5:08 pm

No problem. Wink

Topic archived

Have a good day. Smile
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
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