Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

Ready to contribute?

Amazing! Sign our contributors' agreement and then join us on GitHub.

Vanilla 2.2.1 is now available.
Please upgrade to 2.1.x here. The 2.0 branch is no longer being updated.

Hiding no poll message?

This discussion is related to the Poll addon.
edited March 2011 in Vanilla 2.0 Help
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.