Adding a poll

Post

Posted
Rating:
Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 (Liked by Adam Edington)
#5963 (In Topic #1235)
I am currently testing security settings.  I would like the usergroup I am testing to be able to Add a new poll.  I have verified permissions and they look correct. 

Going from Social->Polls will take me to the "Poll archive" page, which lists all of the available polls.  From here, I am not seeing an option to "Add" (or create) a new poll.  I am finding that you need to actually "view" an existing poll in order to see the "Add" option (at the bottom of the form next to View results).  That doesn't seem very intuitive to me.

Am I missing something?  Is there, perhaps, a way to have the "Add" poll option be available in a more intuitive place (like at the bottom of the Poll archive page, for exampe)?

Thanks in advance for your help!
 

Post

Posted
Rating:
#5967
Right, that's how it is, and I agree it's not very good. I just improved it for v11.

I'm not going to commit that change for v10 as it's not a bug and we shouldn't actively add features to people's sites that may break people's pre-existing assumptions, but I quickly made a patch you can apply manually, and then you can save your altered version as an override (site/pages/modules_custom/polls.php).

Code (Diff)

diff --git a/site/pages/modules/polls.php b/site/pages/modules/polls.php
index 5f1b4a0cd..22e38ad4d 100644
--- a/site/pages/modules/polls.php
+++ b/site/pages/modules/polls.php
@@ -265,7 +265,14 @@ class Module_polls
     {
         $content = do_block('main_multi_content', array('param' => 'poll', 'efficient' => '0', 'zone' => get_zone_name(), 'sort' => 'recent', 'max' => '20', 'no_links' => '1', 'pagination' => '1', 'give_context' => '0', 'include_breadcrumbs' => '0', 'block_id' => 'module', 'guid' => 'module'));
 
-        return do_template('PAGINATION_SCREEN', array('_GUID' => 'bed3e31c98b35fea52a991e381e6cfaa', 'TITLE' => $this->title, 'CONTENT' => $content));
+        // Action links
+        if ((has_actual_page_access(null, 'cms_polls', null, null)) && (has_submit_permission('mid', get_member(), get_ip_address(), 'cms_polls'))) {
+            $submit_url = build_url(array('page' => 'cms_polls', 'type' => 'add', 'redirect' => get_self_url(true, false)), get_module_zone('cms_polls'));
+        } else {
+            $submit_url = new Tempcode();
+        }
+
+        return do_template('PAGINATION_SCREEN', array('_GUID' => 'bed3e31c98b35fea52a991e381e6cfaa', 'TITLE' => $this->title, 'CONTENT' => $content, 'ADD_URL' => $submit_url));
     }
 
     /**
 

Post

Posted
Rating:
#5971

Chris Graham said

Right, that's how it is, and I agree it's not very good. I just improved it for v11.

I'm not going to commit that change for v10 as it's not a bug and we shouldn't actively add features to people's sites that may break people's pre-existing assumptions, but I quickly made a patch you can apply manually, and then you can save your altered version as an override (site/pages/modules_custom/polls.php).

Code (Diff)

diff --git a/site/pages/modules/polls.php b/site/pages/modules/polls.php
index 5f1b4a0cd..22e38ad4d 100644
--- a/site/pages/modules/polls.php
+++ b/site/pages/modules/polls.php
@@ -265,7 +265,14 @@ class Module_polls
     {
         $content = do_block('main_multi_content', array('param' => 'poll', 'efficient' => '0', 'zone' => get_zone_name(), 'sort' => 'recent', 'max' => '20', 'no_links' => '1', 'pagination' => '1', 'give_context' => '0', 'include_breadcrumbs' => '0', 'block_id' => 'module', 'guid' => 'module'));
 
-        return do_template('PAGINATION_SCREEN', array('_GUID' => 'bed3e31c98b35fea52a991e381e6cfaa', 'TITLE' => $this->title, 'CONTENT' => $content));
+        // Action links
+        if ((has_actual_page_access(null, 'cms_polls', null, null)) && (has_submit_permission('mid', get_member(), get_ip_address(), 'cms_polls'))) {
+            $submit_url = build_url(array('page' => 'cms_polls', 'type' => 'add', 'redirect' => get_self_url(true, false)), get_module_zone('cms_polls'));
+        } else {
+            $submit_url = new Tempcode();
+        }
+
+        return do_template('PAGINATION_SCREEN', array('_GUID' => 'bed3e31c98b35fea52a991e381e6cfaa', 'TITLE' => $this->title, 'CONTENT' => $content, 'ADD_URL' => $submit_url));
     }
 
     /**
 


Excellent.  Thanks Chris.

I'll check this updated code out first thing tomorrow.  I agree we don't want to break anybody's pre-existing assumptions.  That would not be helpful.  But thanks for providing me with an interim fix…since my site members will be new to Composr.

Post

Posted
Rating:
#5973

Chris Graham said

Right, that's how it is, and I agree it's not very good. I just improved it for v11.

I'm not going to commit that change for v10 as it's not a bug and we shouldn't actively add features to people's sites that may break people's pre-existing assumptions, but I quickly made a patch you can apply manually, and then you can save your altered version as an override (site/pages/modules_custom/polls.php).

Code (Diff)

diff --git a/site/pages/modules/polls.php b/site/pages/modules/polls.php
index 5f1b4a0cd..22e38ad4d 100644
--- a/site/pages/modules/polls.php
+++ b/site/pages/modules/polls.php
@@ -265,7 +265,14 @@ class Module_polls
     {
         $content = do_block('main_multi_content', array('param' => 'poll', 'efficient' => '0', 'zone' => get_zone_name(), 'sort' => 'recent', 'max' => '20', 'no_links' => '1', 'pagination' => '1', 'give_context' => '0', 'include_breadcrumbs' => '0', 'block_id' => 'module', 'guid' => 'module'));
 
-        return do_template('PAGINATION_SCREEN', array('_GUID' => 'bed3e31c98b35fea52a991e381e6cfaa', 'TITLE' => $this->title, 'CONTENT' => $content));
+        // Action links
+        if ((has_actual_page_access(null, 'cms_polls', null, null)) && (has_submit_permission('mid', get_member(), get_ip_address(), 'cms_polls'))) {
+            $submit_url = build_url(array('page' => 'cms_polls', 'type' => 'add', 'redirect' => get_self_url(true, false)), get_module_zone('cms_polls'));
+        } else {
+            $submit_url = new Tempcode();
+        }
+
+        return do_template('PAGINATION_SCREEN', array('_GUID' => 'bed3e31c98b35fea52a991e381e6cfaa', 'TITLE' => $this->title, 'CONTENT' => $content, 'ADD_URL' => $submit_url));
     }
 
     /**
 


This worked beautifully.  Thank you!

One more quick question.  I'm planning on doing a new poll probably once a week.  That means the list of polls on the Poll archive page can be quite long.  As is, it displays the full results of each Poll…so the page is quite long (even with just 6 polls, at present).  

Does this page paginate?  Or is there a way to only list the Polls by title/question in order to make the poll list more compact?

Post

Posted
Rating:
#5974
Paginates to 20 per screen.

Post

Posted
Rating:
#5976

Chris Graham said

Paginates to 20 per screen.

Okay, still makes for a fairly long page, but definitely works.  Thanks Chris.

Post

Posted
Rating:
#5978
If you want to tweak it, you can see it in the code above.
What would you suggest? Maybe I'll commit the change for v11.

EDIT: If I lowered it it'd be inconsistent with other default paginations. It's very much a preference, some like to scroll without having to keep clicking through, others like quicker loading pages. In v11 the templates can configure this without PHP changes.
 

Last edit: by Chris Graham

Post

Posted
Rating:
Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 (Liked by Adam Edington)
#5982

Chris Graham said

If you want to tweak it, you can see it in the code above.
What would you suggest? Maybe I'll commit the change for v11.

EDIT: If I lowered it it'd be inconsistent with other default paginations. It's very much a preference, some like to scroll without having to keep clicking through, others like quicker loading pages. In v11 the templates can configure this without PHP changes.
 

It's important to be consistent.  I definitely support that.

Basically, the Poll archive page is a brief list of available polls.  It also has a meaningful and unique heading (i.e. the poll question).  Seems like just listing the heading/poll question will expedite finding the poll you are interested in and also shorten the page length (or at least allow for more polls to appear on a page, thus shortening the number of pages).  Once you find the poll you are looking for (to edit or view results) you can select if from the list.  That's just me thinking out loud, anyway.

Hopefully this wouldn't impact your pagination logic, as you are still passing in content.  But the content would be a list of poll headings (with associated link to the actual poll) and not the full poll content (i.e. results) for each poll.

Post

Posted
Rating:
Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 (Liked by Adam Edington)
#5985
You'll be able to template that in in v11 if you want. The poll archive template invokes the main_multi_content block, which now supports multiple rendering modes similar to how catalogues currently do.

Post

Posted
Rating:
#5986

Chris Graham said

You'll be able to template that in in v11 if you want. The poll archive template invokes the main_multi_content block, which now supports multiple rendering modes similar to how catalogues currently do.

Sounds great.  Looking forward to checking out v11.  

Thanks Chris.
5 guests and 0 members have recently viewed this.