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 add an automatic poll like here on the support forum?

View previous topic View next topic Go down

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

Post by Guest on 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

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 on 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
Helper
Helper

Male Posts : 767
Reputation : 51
Language : English - French?
Location : Druid Hill Park

http://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 on 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.)

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 on October 4th 2015, 3:41 pm

Bump

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 on 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
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://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 on October 4th 2015, 4:29 pm

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

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 on 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
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://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 on October 4th 2015, 5:07 pm

Okay, thanks.
topic solved

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 on October 4th 2015, 5:08 pm

No problem. Wink

Topic archived

Have a good day. Smile

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
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