Jump to content

Site Poll Block


Aiwa

Recommended Posts

%7Boption%7D



File Name: Site Poll Block

File Submitter: Aiwa

File Submitted: 14 Jul 2012

File Category: User and Social Engagement

Supported Versions: IP.Board 3.3.x, IP.Board 3.4.x, IP.Content 2.3.x



Do you like having polls on your IP.Content homepage?
Do you find it cumbersome to have to go into your Admin CP to change the link to the topic every time you have a new poll to display?

If so, this is the block for you.

Plugin config allows you to specify which FORUM to pull polls from. It will automatically pull the LATEST poll from whatever forum you specify. If you want a little more control, you can even have it set to only pull the latest PINNED poll. So all you have to do from the front end is pin or unpin your polls to control which is displayed on the front page!

You also have control over what groups can see your poll. You should note, however, that forum permissions are still honored. If the member / guest does not have permission to read or reply to the toipc, they won't be able to submit a vote or see the results. If they can read the topic, they can see the results but not vote. If they can reply to the topic, the block will be fully functional.

This block can be easily styled to meet your sites needs!

I have tested with the supported versions on the right, however it should work with IP.Board 3.2.x and IP.Content 2.2.x.

Like this file? Like the support provided?
Donations are always welcome
%7Boption%7D

For support, please create an account then submit a ticket.



here to download this file

Link to comment
Share on other sites

  • Replies 101
  • Created
  • Last Reply

Absolutely. The block can be styled however you like.

ACP > Look and Feel > Select your skin > Global > kc_site_poll

I wanted to make sure that the template was easily editable in the event someone wanted to make some tweaks to it.

Link to comment
Share on other sites

Thanks for that.

Question, what does the CDATA portion of the template do as ideally we want to remove the 'Site Poll' part and replace that with our own title. I had though that handled it but alas it looks like not.

Ideally we wish to completely remove the surrounding containers, and just have:

Current Poll
Poll Title hyperlinked to the thread
Votes and bars in the usual standard IP.Board text

And remove the vote count and 'delete' button

That is a very clean layout.

Any tips?

Link to comment
Share on other sites

Using:


<script type='text/javascript'>

//<![CDATA[

ipb.templates['poll_voters'] = new Template("<h3 class='bar'>{$this->lang->words['poll_voted_for']} #{title}</h3><div class='ipsPad'>#{content}</div>");

//]]>

</script>

<div class="m1maintitle" ><a href='http://www.smartphonegurus.com/forums/forum/107-polls//'>&nbsp;Polls</a></div>

<div class='ipsBox_container'>

<form action="{parse url="app=forums&amp;module=extras&amp;section=vote&amp;t={$topicData['tid']}&amp;st={$this->request['st']}&amp;do=add&amp;secure_key={$this->member->form_hash}" base="public"}" name='pollForm' method="post">

<if test="publicPollNotice:|:$this->settings['poll_allow_public'] AND $poll['poll_view_voters'] AND ! $showResults">

<div class='message unspecified'>{$this->lang->words['poll_public_notice']}</div>

</if>

<table class='ipb_table'>

<foreach loop="poll_questions:$pollData as $questionID => $questionData">

<tr><td class='row2'><a href="{parse url="showtopic={$topicData['tid']}" base="public" seotitle="{$topicData['title_seo']}"}"><h3 class='rounded'>{$pollData[ $questionID ]['question']}</h3></a></td></tr> <tr><td class='row2'>

<if test="noGuestVote:|:! $this->settings['allow_result_view'] AND ! $this->memberData['member_id']">

	 {$this->lang->words['poll_noview_guest']}

<else />

	 <ol>

	 <foreach loop="poll_choices:$pollData[ $questionID ]['choices'] as $choiceID => $choiceData">

	 <if test="showingResults:|:$showResults">

	 <li>

		 <span class='answer'><if test="hasVoters:|:is_array( $choiceData['voters'] ) AND in_array( $this->memberData['member_id'], array_keys( $choiceData['voters'] ) )"> {parse replacement="your_vote"} </if>{$choiceData['choice']}</span>

		 <if test="viewVoters:|:$poll['poll_view_voters'] AND is_array( $choiceData['voters'] ) AND $this->settings['poll_allow_public'] AND $choiceData['votes']">

		 <a href='#' class='votes' id='l_voters_{$questionID}_{$choiceID}' title='{$this->lang->words['poll_view_voters']}'>({$choiceData['votes']} {$this->lang->words['poll_votes']} [{$choiceData['percent']}%] - <strong>{$this->lang->words['poll_view']}</strong>)</a>

		 <else />

		 <span class='votes'> ({$choiceData['votes']} {$this->lang->words['poll_votes']} [{$choiceData['percent']}%])</span>

		 </if>

		 <if test="votersJs:|:$poll['poll_view_voters'] AND is_array( $choiceData['voters'] ) AND $this->settings['poll_allow_public'] AND $choiceData['votes']">

		 <script type='text/javascript'>

		 $('l_voters_{$questionID}_{$choiceID}').observe('click', ipb.topic.showVoters.bindAsEventListener( this, {$questionID}, {$choiceID} ) );

		 if( Object.isUndefined( ipb.topic.poll[ $questionID ] ) ){

		 ipb.topic.poll[ $questionID ] = [];

		 }

		 var users = "";

		 <foreach loop="poll_voters:$choiceData['voters'] as $id => $member">

		 users += "<a href='{parse url="showuser={$member['member_id']}" base="public" seotitle="{$member['members_seo_name']}" template="showuser"}'>{$member['members_colored_name']}</a><if test="lastVoter:|:$member['_last'] == 0">, </if>";

		 </foreach>

		 ipb.topic.poll[ $questionID ][ $choiceID ] = { name: "{$choiceData['choice']}", users: users};

		 </script>

		 </if>

		 <p class='progress_bar topic_poll' title='{$this->lang->words['poll_percent_of_vote']} {$choiceData['percent']}%'>

		 <span style='width: {$choiceData['percent']}%'><span>{$this->lang->words['poll_percent_of_vote']} {$choiceData['percent']}%</span></span>

		 </p>

	 </li>

	 <else />

	 <if test="multiVote:|:$choiceData['type'] == 'multi'">

		 <li><input type='checkbox' id='choice_{$questionID}_{$choiceID}' name='choice_{$questionID}_{$choiceID}' value='1' class='input_check' /> <label for='choice_{$questionID}_{$choiceID}'>{$choiceData['choice']}</label></li>

	 <else />

		 <li><input type='radio' name='choice[{$questionID}]' id='choice_{$questionID}_{$choiceID}' class='input_radio' value='{$choiceID}' /> <label for='choice_{$questionID}_{$choiceID}'>{$choiceData['choice']}</label></li>

	 </if>

	 </if>

	 </foreach>

	 </ol>

</if>

</td></tr>

</foreach>

</table>

</form>

</div>



I've now got it to look like the attached which I can live with f I can get rid of the 'Site Poll' part at the top.

If you can assist on that it'd be wonderful!

Link to comment
Share on other sites

Looks like the CCS template I used has that header hard coded into it... Hadn't noticed that...

I'm repackaging the download now give me a few minutes to go over everything again and make sure it's all there... All you'll have to do is upload the the new plugin.php file and delete and import the new block. You do NOT have to re-install the hook. All of your template changes will be retained. So you don't have to re-do what you've already done. As soon as you re-install the block the header 'site poll' should disappear.

Link to comment
Share on other sites

I was mistaken.. I needed to update the template to include the header and had to add a variable to it...

You still don't need to re-install the hook, but you need to go into the template 'kc_site_poll', click variables, add this to the end: $title

You won't use it, but you need it there to not break the template call.

1.0.1 has been uploaded to the MP.

Link to comment
Share on other sites

About the vote counts.

Find this in the skin template. You can take out the $choiceData['votes'] and $this->lang->words['poll_votes'] to not show the vote count. You'll want to remove it from both the link and the span.


		  <a href='#' class='votes' id='l_voters_{$questionID}_{$choiceID}' title='{$this->lang->words['poll_view_voters']}'>({$choiceData['votes']} {$this->lang->words['poll_votes']} [{$choiceData['percent']}%] - <strong>{$this->lang->words['poll_view']}</strong>)</a>

		 <else />

		  <span class='votes'> ({$choiceData['votes']} {$this->lang->words['poll_votes']} [{$choiceData['percent']}%])</span>

Link to comment
Share on other sites

Hmm my team decided they liked the vote counts so they will stay.

Block now permanently in place, the only comments I've had back from the team are:

  • The vote question is lighter than the rest of the text we use on the page.
  • The light blue background looks out of place with the plain white backdrop we use on the page.

Any ideas as to how those can be changed?
Link to comment
Share on other sites

Background is easy...


<td class='row2'>

Take out 'row2' Change the <td> class below to 'm1sectionTitle'


<tr><td class='row2'><a href="{parse url="showtopic={$topicData['tid']}" base="public" seotitle="{$topicData['title_seo']}"}"><h3 class='rounded'>{$pollData[ $questionID ]['question']}</h3></a></td></tr>

Once you get the background gone, you'll notice it has a border.. Change class to 'mawide'


<div class='ipsBox_container'>



I used chrome to change the elements live... The below screenshot is what the above mod should get you. Mind you i'm using 1920x1200 res...

Looks good.. (w00t)

Link to comment
Share on other sites

This is very much appreciated :smile: I'd not have worked this out in a million years.

The template now looks as per the following (if I edited it correctly):


<script type='text/javascript'>

//<![CDATA[

ipb.templates['poll_voters'] = new Template("<h3 class='bar'>{$this->lang->words['poll_voted_for']} #{title}</h3><div class='ipsPad'>#{content}</div>");

//]]>

</script>

<div class="m1maintitle" ><a href='http://www.smartphonegurus.com/forums/forum/107-polls//'>&nbsp;Polls</a></div>

<div class='mawide'>

<form action="{parse url="app=forums&amp;module=extras&amp;section=vote&amp;t={$topicData['tid']}&amp;st={$this->request['st']}&amp;do=add&amp;secure_key={$this->member->form_hash}" base="public"}" name='pollForm' method="post">

<if test="publicPollNotice:|:$this->settings['poll_allow_public'] AND $poll['poll_view_voters'] AND ! $showResults">

<div class='message unspecified'>{$this->lang->words['poll_public_notice']}</div>

</if>

<table class='ipb_table'>

<foreach loop="poll_questions:$pollData as $questionID => $questionData">

<tr><td class='m1sectionTitle'><a href="{parse url="showtopic={$topicData['tid']}" base="public" seotitle="{$topicData['title_seo']}"}"><h3 class='rounded'>{$pollData[ $questionID ]['question']}</h3></a></td></tr>

<tr><td>

<if test="noGuestVote:|:! $this->settings['allow_result_view'] AND ! $this->memberData['member_id']">

	 {$this->lang->words['poll_noview_guest']}

<else />

	 <ol>

	 <foreach loop="poll_choices:$pollData[ $questionID ]['choices'] as $choiceID => $choiceData">

	 <if test="showingResults:|:$showResults">

	 <li>

		 <span class='answer'><if test="hasVoters:|:is_array( $choiceData['voters'] ) AND in_array( $this->memberData['member_id'], array_keys( $choiceData['voters'] ) )"> {parse replacement="your_vote"} </if>{$choiceData['choice']}</span>

		 <if test="viewVoters:|:$poll['poll_view_voters'] AND is_array( $choiceData['voters'] ) AND $this->settings['poll_allow_public'] AND $choiceData['votes']">

		 <a href='#' class='votes' id='l_voters_{$questionID}_{$choiceID}' title='{$this->lang->words['poll_view_voters']}'>({$choiceData['votes']} {$this->lang->words['poll_votes']} [{$choiceData['percent']}%] - <strong>{$this->lang->words['poll_view']}</strong>)</a>

		 <else />

		 <span class='votes'> ({$choiceData['votes']} {$this->lang->words['poll_votes']} [{$choiceData['percent']}%])</span>

		 </if>

		 <if test="votersJs:|:$poll['poll_view_voters'] AND is_array( $choiceData['voters'] ) AND $this->settings['poll_allow_public'] AND $choiceData['votes']">

		 <script type='text/javascript'>

		 $('l_voters_{$questionID}_{$choiceID}').observe('click', ipb.topic.showVoters.bindAsEventListener( this, {$questionID}, {$choiceID} ) );

		 if( Object.isUndefined( ipb.topic.poll[ $questionID ] ) ){

		 ipb.topic.poll[ $questionID ] = [];

		 }

		 var users = "";

		 <foreach loop="poll_voters:$choiceData['voters'] as $id => $member">

		 users += "<a href='{parse url="showuser={$member['member_id']}" base="public" seotitle="{$member['members_seo_name']}" template="showuser"}'>{$member['members_colored_name']}</a><if test="lastVoter:|:$member['_last'] == 0">, </if>";

		 </foreach>

		 ipb.topic.poll[ $questionID ][ $choiceID ] = { name: "{$choiceData['choice']}", users: users};

		 </script>

		 </if>

		 <p class='progress_bar topic_poll' title='{$this->lang->words['poll_percent_of_vote']} {$choiceData['percent']}%'>

		 <span style='width: {$choiceData['percent']}%'><span>{$this->lang->words['poll_percent_of_vote']} {$choiceData['percent']}%</span></span>

		 </p>

	 </li>

	 <else />

	 <if test="multiVote:|:$choiceData['type'] == 'multi'">

		 <li><input type='checkbox' id='choice_{$questionID}_{$choiceID}' name='choice_{$questionID}_{$choiceID}' value='1' class='input_check' /> <label for='choice_{$questionID}_{$choiceID}'>{$choiceData['choice']}</label></li>

	 <else />

		 <li><input type='radio' name='choice[{$questionID}]' id='choice_{$questionID}_{$choiceID}' class='input_radio' value='{$choiceID}' /> <label for='choice_{$questionID}_{$choiceID}'>{$choiceData['choice']}</label></li>

	 </if>

	 </if>

	 </foreach>

	 </ol>

</if>

</td></tr>

</foreach>


</table>

</form>

</div>



The only small issue now is that there appears to be two very pale horizontal lines across the poll table, difficult to see, but there.

Two images attached one showing it natively and the other marked up with arrow pointing at the lines and showing the start / end positions.

If we can get rid of those this is perfect!

Link to comment
Share on other sites

If it helps at all the template for the block below the poll on the portal is as per:


<div class='mawide'>

<div class="m1maintitle" ><a href='http://www.smartphonegurus.com/forums/index.php?/forum/5-reviews/'>&nbsp;Reviews</a></div>

	    <if test="is_array( $records ) && count( $records )">

	    <div class='msectionBox' {parse striping="feed_striping" }>

		  <foreach loop="$records as $r">

<php>

$this->images = '';

$this->DB->build( array( 'select' => 'rattach.attach_location', 'from' => array('attachments'=>'rattach'),  'where'=>'rattach.attach_rel_id=' .$r['topic_firstpost'],  'order' => 'rattach.attach_id asc','limit' => array(0,1),'limit' => array(0,1) ));

$this->DB->execute();

while( $rattach = $this->DB->fetch() )

{

$this->images .= "<img class='photo left ipsPad' width='225';' src='http://www.smartphonegurus.com/forums/uploads/{$rattach['attach_location']}' />";

}</php>

{$this->images}

		  <div class='m1sectionTitle {parse striping="feed_striping"}'><a href='{$r['url']}' rel='bookmark' title='{$r['title']}'>{$r['title']}</a>

		  </div>


<span class='desctext'>{IPSText::truncate( strip_tags($r['content']), 300 )}</span><a href='{$r['url']}' rel='bookmark' title='{$r['title']}' >Read more &rarr;</a>

<br style="clear:left;"/>

<div class='m1rest'><br />

</div>


<br style="clear:left;"/>			   

			    </foreach>

			   </div>

			    </if>


</div>

Link to comment
Share on other sites


Will that not mess up tables elsewhere on the site though?



It would....

You can also remove the class tag from the <table>... remove class='ipb_table'.

The block will look a little different... things will scrunch a bit... test it out..
Link to comment
Share on other sites

I did try the CSS edit first it worked but as discussed I was worrying about other templates being messed up.

But I removed the class from the table and as far as I can see it looks completely wonderful :)

Now if you can PM me a PayPal address I'll make a donation for the assistance, I've not got a lot of free cash but you deserve something for the help! It would have taken me a long long time to get there!

This assistance is very very much appreciated!

Link to comment
Share on other sites

I appreciate that.

When you're styling, one thing that can be extremely helpful is using Google Chrome's 'inspect element'.

Right click what you're wanting to change, and hit inspect element. You can add, remove, change, do whatever you want to the HTML or CSS on the page to find the tweaks that will give you the look you are after. It has saved me many an hour as well trying to find the element that was causing colors to be FUBAR.

Link to comment
Share on other sites

I thought you might :)

What advantage would that give?

Aiwa - one slight complaint from one of my team..... sigh. He thinks that the way we have it now that each pair of answer / barchart lines runs into the next answer pair - and asks if there is anyway to add a half line space in between. I thought it doubtful but said I'd ask :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...