Polls not Appearing in All Polls

I have a new setup with Dolphin 6.1.4. When a user adds a poll, it does not appear in the "All Polls" section. Is there a setting somewhere to change that?

 

I've searched all over the documentation and search the forums, but I can't find an answer. The best I could find was someone else reported this a long time ago and the answer was, "Works for me."

Quote · 5 Nov 2009

No idea about that "works for me."  I haven't researched it myself yet, but it seems pretty apparent that yes, the user polls don't appear there.  The polls page simply has the "site polls" and "my polls" options.

 

I was planning on looking at the code for the poll box on the front page and code something similar to it in a new php file and link to it under the polls menu.  Once two user polls have been created, there seems to be no way currently to see the other ones except luck via the top or random polls.

Quote · 6 Nov 2009

So I'm guessing this is how the polls are supposed to work?

 

Thanks for your comments, CelticCurls. Since no one else has said anything, can anyone confirm for me that creating polls is an exercise for an individual? I'm just wondering if there is any way to have all polls show up in the All Polls section of the site.

Quote · 9 Nov 2009

Yea, I did already browse around the function that's called for the homepage poll box and it doesn't look like it would be too hard to convert, just insert the pagination function and sort them and you'd be done.

 

I did look at the polls file itself, thinking it might have functionality similar to search.php (where the advanced search is hidden by default), but it looks like it's a no-go.  As far as I can tell this is "correct" functionality in showing only site polls.  User polls only appear on individual profiles and the most recent two on the homepage by default.

 

It would also be really nice to have the "previous" and "next" buttons on the poll homepage box the way the members, blogs, and photo boxes have as well.  It shouldn't be too hard either.

 

If someone doesn't beat me to it, I'll try to let you know.

Quote · 10 Nov 2009

Ok, finally got around to this.  Here's what I did:

 

1. Create polls_members.php

Just make a copy of the polls.php file. 

1.1 Strip out all the functions at the bottom.

1.2 Add this line to include the profiles.inc.php:

require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );

 

1.3 Change the page code line to point to this new function, PollPages():

$_page_cont[$_ni]['page_main_code'] = PollPages( );

 

1.4 Add this new function and set $max_num to however many polls you want per page:

function PollPages( )
{
 $max_num = 10;


     $query = "
  SELECT
   `id_poll`,
   `id_profile`,
   `Profiles`.*
  FROM `ProfilesPolls`
  LEFT JOIN `Profiles` ON
   `id_profile` = `Profiles`.`ID`
  WHERE
   `poll_status` = 'active'
   AND `poll_approval`
  ";

 $query .= " ORDER BY id_poll DESC";


 $aNum = db_arr( "SELECT COUNT(`id_poll`) FROM `ProfilesPolls` ");
 $num = (int)$aNum[0];

 


 if( $num )
 {
  $pages = ceil( $num / $max_num );
  $page = (int)$_GET['page'];


  
  if( $page < 1 )
   $page = 1;
  if( $page > $pages )
   $page = $pages;


  $sqlLimitFrom = ( $page - 1 ) * $max_num;
  $sqlLimit = " LIMIT $sqlLimitFrom, $max_num";

  $poll_res = db_res( $query.$sqlLimit );


  while ( $poll_arr = mysql_fetch_array( $poll_res ) )
  {
   $sPic = get_member_icon( $poll_arr['ID'], 'left');
   $sPoll = ShowPoll( $poll_arr['id_poll'] );

   $sNickName = $poll_arr['NickName'];
   $sNickNameLnk = getProfileLink($poll_arr['ID']);

   $ret .= <<<EOF
<div class="blog_block">
 <div class="icon_block">
  {$sPic}
 </div>
 <div class="blog_wrapper_n" style="width:80%;border:1px dashed #CCCCCC;">
  <div class="blog_subject_n">
   <a href="{$sNickName}" class="bottom_text">
    {$sNickName}
   </a>
  </div>
  <div class="blogSnippet">
   {$sPoll}
  </div>
 </div>
</div>
<div class="clear_both"></div>
EOF;
  }

 

  if( $pages > 1 )
  {
   $pagination =
    '<div class="photos_pages">'.
     genPagination( $pages, $page, $_SERVER['PHP_SELF']."?page={page}" ).
    '</div>';
   
   $ret = $pagination . $ret . $pagination;
  }
 }

 return $ret;
}

 

Perhaps with resizing the widths a bit, you should have room for a skyscraper advertisement on the side too if you want.

 

 

2. Add the "View All" buttons to the Poll block on the homepage:

2.1 Open templates/base/scripts/BxBaseIndex.php

In function getBlockCode_ProfilePoll() find the section:

    $ret .= <<<EOF
<div class="blog_block">
 <div class="icon_block">
  {$sPic}
 </div>
 <div class="blog_wrapper_n" style="width:80%;border:1px dashed #CCCCCC;">
  <div class="blog_subject_n">
   <a href="{$sNickName}" class="bottom_text">
    {$sNickName}
   </a>
  </div>
  <div class="blogSnippet">
   {$sPoll}
  </div>
 </div>
</div>
EOF;

   }
  }

 

and after that add (just before the function return statement):

  if( $mode == 'admin' )
   $ret .= '<br /><center><b><a href="polls.php">View All</a></b></center>';
  else
   $ret .= '<center><b><a href="polls_members.php">View All</a></b></center>';

 

That will add a "View All" button that points to the site polls on the Site Polls tab and points to the Profile Polls page for the latest, random, and top poll tabs.

 

3. Add the Profile Polls page in the Admin|Buiders|Menu Builder.

Add the entry for the new page in and set the language key.  I renamed "All Polls" to "Site Polls" too.

 

Hope that helps. Smile

Quote · 11 Feb 2010
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.