How to implement polls in Drupal using Polls module

In websites we can gather information from users in different ways like surveys, polls etc.

Here we are discussing how to implement polls in a Drupal website.

What are website Polls?

Polls on websites are quick, interactive tools used to ask users a single question or a few simple questions, often with predefined answer choices. They are designed to quickly gauge the opinions or preferences of visitors on specific topics, providing immediate feedback. Polls are typically easy to complete and help increase user engagement on the site.

In this article we are discussing how to use Polls module to show polls or surveys in website. 

Polls module allows your site to capture votes on different topics in the form of multiple choice questions.

We will  go through steps to configure polls module and showing how we can show polls widget at front end. 

Install Polls module 

https://www.drupal.org/project/poll

After installation you can see Poll tab in content page /admin/content

Click on Add a Poll button 

You could see below Add Poll form, provide your question and choices that users can select.

Add question and choices  as below.

You can also select below options if needed.

In polls tab you can see our newly created question and total votes.

Click on above question redirects to below poll page.

Users can vote and see the results as below.

There will be option to cancel the votes. All these configurations you can customize.

You can create different types of Polls with required fields in Configuration->Poll setting page  in path /admin/config/content/poll

You can create new fields to your Poll and arrange elements in manage form display.

In Next sections we are discussing  how we can embed this Poll widget inside body content and in blocks.

Placing Poll inside content body

Install below contributed modules.

Embed – https://www.drupal.org/project/embed

Entity embed – https://www.drupal.org/project/entity_embed

After installation Go to Configuration -> Content authoring -> Text formats and editors.

Path- /admin/config/content/formats

Select text format in which you want poll entity need to be embedded in below and click configure,

Then under enabled filters select Display embedded entities.

Make sure you have any one text editor selected.

You can see that one of the E buttons is your Poll entity button. You can confirm this by hovering on it.

Drag and drop this to your active toolbar.

Then click save configuration.

While adding content you can drag and show the Poll in content pages.

Placing Poll as  as a block

You can go through below steps to show Poll as a block and can be placed at a region from block lay out page.These points took from this page. refer the same.

Create Block type.

1. Go to structure>Block layout>Custom block library tab>Block types sub-tab.

2. Click on +Add custom block type.

3. Give it a label such as: Poll block and Save.

4. Click on Manage fields next to the Poll block in the list.

5. Add a reference field to other and label it Poll Question.

6. For the Type of item to reference, select Poll. If you want to have multiple questions showing in the block, change the value of Allowed number of values. Save.

7. If you want to add instructions for your users, do it now. Otherwise, save.

8. Lastly, Manage Display by hiding the body field (unless you plan on using it), hide the label to the poll question, and set the format to show the full entity. Save.

Now for the block itself:

1. Go to Structure>Block layout>Custom block library tab>.

2. Click +Add custom block

3. Select Poll block

4. Complete the form by using the Poll question reference field to reference the poll question entity you have already created.

5. Save.

6. Place the block in a region so you can see it.

Note – Make sure below permissions are enabled for anonymous users if anonymous users are not seeing Poll at front end.

Get Free E-book
Get a free Ebook on Drupal 8 -theme tutorial
I agree to have my personal information transfered to MailChimp ( more information )
if you like this article Buy me a Coffee this will be an ispiration for me to write articles like this.

You may also like...