Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Hiding no poll message?

edited March 2011 in Vanilla 2.0 - 2.8
In my case, 99.99% of the discussions will NOT have a poll. Is there anyway then to only show the poll info in the sidebar when there IS a poll? Right now is shows "There is no poll attached to this discussion" for every discussion and clutters the screen. If not, could the be added to the next release, perhaps as an option?

Comments

  • I'm also interested in this.
  • edited May 2011
    OK, I think I figured it out. In class.pollmodule.php, starting with line 81, you need to change this:

    <div class="Box"> <h4><?= T('Poll')?></h4> <?if (!empty($this->_PollData)):?> <br /> <h5><?= stripslashes($this->_PollData->title)?></h5> <ul class="poll-answers"> <? foreach ($this->_PollAnswers->Result() as $Answer):?> <? $Percentage = floor(($Answer->votes / $this->_PollVotes) * 100)?> <li class="answer-block"> <?= Anchor(stripslashes($Answer->title), 'vanilla/discussion/poll/'.$this->_PollData->id.'/vote/'.$Answer->id)?> <br /> <div class="poll-bar" style="width:<?= floor(($Answer->votes / $this->_PollVotes) * 100) + 1?>%;"></div> <span class="poll-percentage"><?= $Percentage?>% </span><span class="poll-numvotes">(<?= $Answer->votes?> votes)</span> <br /> </li> <?endforeach?> </ul> <br /> <?if($Session->CheckPermission('Plugins.Poll.Manage')):?> <ul class="poll-options-list"> <li><?= Anchor(T('Edit poll'), 'vanilla/discussion/editpoll/'.$this->_PollData->id, 'Reset poll')?></li><li><?= Anchor(T('Reset poll'), 'vanilla/discussion/poll/'.$this->_PollData->id.'/reset', 'Reset poll')?></li><li><?= Anchor(T('Delete poll'), 'vanilla/discussion/poll/'.$this->_PollData->id.'/delete', 'Delete poll')?></li> </ul> <?endif?> <?else:?> <?if($Session->CheckPermission('Plugins.Poll.Manage')):?> <ul class="poll-options-list"> <li><?= Anchor(T('Attach a poll'), 'vanilla/discussion/attachpoll/'.$this->ID, 'Attach a poll')?></li> </ul> <?else:?> <?= T('No poll attached to this discussion.') ?> <?endif?> <?endif?> </div>

    into this:

    <?if (!empty($this->_PollData)):?> <div class="Box"> <h4><?= T('Poll')?></h4> <br /> <h5><?= stripslashes($this->_PollData->title)?></h5> <ul class="poll-answers"> <? foreach ($this->_PollAnswers->Result() as $Answer):?> <? $Percentage = floor(($Answer->votes / $this->_PollVotes) * 100)?> <li class="answer-block"> <?= Anchor(stripslashes($Answer->title), 'vanilla/discussion/poll/'.$this->_PollData->id.'/vote/'.$Answer->id)?> <br /> <div class="poll-bar" style="width:<?= floor(($Answer->votes / $this->_PollVotes) * 100) + 1?>%;"></div> <span class="poll-percentage"><?= $Percentage?>% </span><span class="poll-numvotes">(<?= $Answer->votes?>)</span> <br /> </li> <?endforeach?> </ul> <br /> <?if($Session->CheckPermission('Plugins.Poll.Manage')):?> <ul class="poll-options-list"> <li><?= Anchor(T('Edit poll'), 'vanilla/discussion/editpoll/'.$this->_PollData->id, 'Reset poll')?></li><li><?= Anchor(T('Reset poll'), 'vanilla/discussion/poll/'.$this->_PollData->id.'/reset', 'Reset poll')?></li><li><?= Anchor(T('Delete poll'), 'vanilla/discussion/poll/'.$this->_PollData->id.'/delete', 'Delete poll')?></li> </ul> <?endif?> <?else:?> <?if($Session->CheckPermission('Plugins.Poll.Manage')):?> <div class="Box"> <h4><?= T('Poll')?></h4> <ul class="poll-options-list"> <li><?= Anchor(T('Attach a poll'), 'vanilla/discussion/attachpoll/'.$this->ID, 'Attach a poll')?></li> </ul> <?else:?> <?endif?> <?endif?> </div>
  • I apologize for the very late bump, but this solution messed up the formatting of my site. I changed the last bit to read:

    <?else:?> <div class="box"> <?endif?> <?endif?> </div>

Sign In or Register to comment.