Fork me on GitHub
Current releases are 2.1.3 (9 Sept 2014) and 2.0.18.13 (5 Aug 2014)

Ready for 2.1? Find out if your plugins are compatible. 2.0 will no longer be updated after Dec 2014.

Hiding no poll message?

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

  • 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.