It would be useful to be able to display a specific poll in a block/widget that can be embedded into pages, perhaps with an option to AJAX-load the results into the block (i.e. instead of redirecting the user to the poll page after they respond).
The current functionality (most recent poll block) doesn't allow for the possibility of there being multiple polls in use on a site.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | poll-add-select-poll-block-2671230-14.patch | 2.61 KB | trwill |
| #8 | poll-add-select-poll-block-707484-8-8.patch | 3.36 KB | trwill |
Comments
Comment #2
jeremylichtman commentedComment #3
jeremylichtman commentedComment #4
berdirI don't understand.
The module provides a block that shows the latest poll. Since there is views support, you could also build a view that would show a poll based on whatever conditions you want instead.
The module shouldn't redirect to the detail page. It submits there, but it uses ajax already and also sets a destination, to make sure that the user stays where he is.
Comment #5
jeremylichtman commentedLet's say you have five polls currently running, and you want to display them in different parts of a (large) site, and you want a content editor (not coder or super admin) to be able to maintain them (and they've had a bit of training in how to use blocks and widgets).
On our end, we're leaning towards creating a custom widget that leverages the poll module, but this is a coding task.
Wouldn't it be easier to have a poll block with a form field that allows specifying which poll to display?
Comment #6
berdirThere are pretty easy ways to just that. For example, create a poll content block type with a reference field and allow to reference and display a view through that.
I'm not sure about adding more hardcoded blocks, so leaving this open to see if more users are interested in that.
The ajax/redirect problems have been fixed elsewhere and things are working pretty well now.
Comment #7
trwill commentedI've done this - will work to submit a patch today at the sprint
Comment #8
trwill commentedHere it is - first attempt at a block for selecting a poll.
Comment #9
blakehall commentedThis patch looks like it should be ready for review.
Comment #10
berdirThanks for starting this, there's quite a bit of cleanup necessary.
Needs to use two spaces instead of tabs (everywhere, not just here)
Default configuration belongs in the defaultConfiguration() method.
You already have an ID. Just load it. You're doing a query to get the ID based on the ID.
hardcoded markup doesn't belong here.
Each block already has a title, no need to duplicate that with another configurable title.
This is also all way too complicated.
Either you have an ID, or if you don't, you load the most recent.
Then you can simplify this to a if (!$current_poll_id) { load latest
afaik this accepts either an ID or an entity, so you don't even have to load it. Not 100% sure about that, though.
Comment #11
prashant114606 commentedLet's assume we need more than one poll to display it on different part of the working sites. You can make use of the contrib module called NodeBlock(https://www.drupal.org/project/nodeblock). When you enable the core module poll it gives a content types called poll under which there a setting option will be available once you will enable the NodeBlock module. Configure it according to your need and you can make all the poll available as block which can be placed on different part of site as per need.
Comment #12
berdirSee #6. You can easily replicate that in D8 by creating blocks with a reference to a poll.
Another possibility would be ctools entity view blocks, but then you need something that exposes the poll as context so it can use it. Easy with static context in page manager/panels but currently not possible for normal blocks.
Comment #13
trwill commentedThis block allows specified polls to be placed in different parts of the site, multiple times. One poll per block can be placed anywhere, multiple times, even using something like Panelizr. I have not given up on this patch and just have been very busy. My apologies for spacing and syntax issues, most of this was copied and pasted (which I think explains the tabs) from a site that I had implemented it on. This included the need for an add'l title (obviously not necessary here). I do want to clean this up and appreciate you taking the time to comment on it @Berdir
Comment #14
trwill commentedUpdated from comments - I don't quite exactly follow w/ default config in #2, so if that's still incorrect lmk and I can update.
Comment #15
trwill commentedComment #16
trwill commentedComment #17
berdirThanks for working on this.
@file should no longer be added to class files.
Would be nice to use injection instead of calling \Drupal
Since both blocks use this, we could make a PollBlockBase class with the inection.
Still lots of tabs.
poll_lookup is a strange name for this, maybe just poll, poll_id or selected_poll?
This will also need tests.
Comment #18
bramdriesenIf this is still a feature people want, it should be re-rolled into a MR and the latest code review remarks should be implemented as well.