1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Which files to edit the poll system?

Discussion in 'XenForo Questions and Support' started by Nomed Senkrad, Sep 25, 2011.

  1. Nomed Senkrad

    Nomed Senkrad Member

    Hi, I want to edit temporarily how the polls on my forum look. I just want to remove the possibility to see the results of the poll, then after the voting is finished, I'll restore the poll back to normal.

    Which files must I modify? If anyone knows, it would be of great help! :p
     
  2. Nomed Senkrad

    Nomed Senkrad Member

    Okay, I found that I can easily edit the "poll_block_result" on the templates, and I prepared the temporarily solution. But now I'm wondering, is it possible to check the date of the poll in the template (or is there a variable I can use for the xen:if)? Nothing too fancy, if the poll is expired then it shows the results, and if not there is a message like "The results of the poll will be visible from $date".

    This could be an acceptable solution.
     
  3. James

    James Well-Known Member

    $poll.close_date

    You should be able to do something like "The results of the poll will be visible from {xen:datetime $poll.close_date}
     
  4. Nomed Senkrad

    Nomed Senkrad Member

    Thanks! But is there a variable like $poll.is_closed that I can use with a xen:if to show or not the poll results?

    Something like this:
    Code:
    <xen:if is="{$poll.is_closed}">
    
    show results
    
    <xen:else />
    message: The results will be visible from date
    
    </xen:if>
     
  5. James

    James Well-Known Member

    $poll.open returns true if the poll is open, so to check if it's closed:
    <xen:if is="!{$poll.open}">

    </xen:if>
     
  6. Nomed Senkrad

    Nomed Senkrad Member

    Thanks, that's perfect! :D
     
  7. Nomed Senkrad

    Nomed Senkrad Member

    Wow, that was quick, it works very good. :p

    This how I modified the code.
    Code:
    <xen:edithint template="polls.css" />
    
    <div>
                <xen:if is="!{$poll.open}">
        <table class="pollResults">
    
        <xen:foreach loop="$poll.responses" key="$pollResponseId" value="$response">
            <tr class="pollResult {xen:if $response.hasVoted, voted}">
                <xen:if is="{$response.hasVoted}">
                    <td class="votedIconCell" title="{xen:phrase your_vote}">*</td>
                <xen:else />
                    <td class="votedIconCell"></td>
                </xen:if>
                <th class="optionText" {xen:if $response.hasVoted, 'title="{xen:phrase your_vote}"'}>
                    {$response.response}
                </th>
                <td class="barCell">
                    <span class="barContainer">
                        <xen:if is="{$response.response_vote_count}"><span class="bar" style="width: {xen:calc "200 * {$response.response_vote_count} / {$poll.voter_count}"}px"></span></xen:if>
                    </span>
                </td>
                <td class="count">
                    <xen:if is="{$poll.public_votes} AND {$response.response_vote_count}">
                        <a href="{xen:link threads/poll/results, $thread, 'poll_response_id={$pollResponseId}'}" class="concealed OverlayTrigger">{xen:phrase x_votes, 'count={xen:number $response.response_vote_count}'}</a>
                    <xen:else />
                        {xen:phrase x_votes, 'count={xen:number $response.response_vote_count}'}
                    </xen:if>
                </td>
                <td class="percentage">
                    <xen:if is="{$poll.voter_count}">
                        {xen:number {xen:calc "100 * {$response.response_vote_count} / {$poll.voter_count}"}, 1}%
                    <xen:else />
                        {xen:number 0, 1}%
                    </xen:if>
                </td>
            </tr>
        </xen:foreach>
        </table>
    
        <xen:if is="{$poll.multiple}">
            <div class="pollNotes">
                <span class="multipleNote muted">{xen:phrase multiple_votes_allowed}</span>
            </div>
        </xen:if>
    
        <xen:else />
                <table class="pollResults">
                    <tr class="pollResult">
                <th class="optionText">
                The results of the poll will be visible from {xen:datetime $poll.close_date}
                </th>
                    </tr>
        </table>
    </xen:if>
    </div>
    But there's is a problem, the polls that haven't an expiration date will never show any result.
    Is there a variable for this too, so I can check if the poll is closed and if it has a limited period for the votation?

    Something I can use like this:
    Code:
    <xen:if is="!{$poll.open} OR !{$poll.expire}">
     
  8. James

    James Well-Known Member

    I'm mobile atm but if you create a poll that doesn't expire, then check the $poll.close_date variable, it should show 0, false or something like that.
     
  9. Nomed Senkrad

    Nomed Senkrad Member

    Awesome! Thank you so much, it's perfect!

    [​IMG]
     

Share This Page