Forum for discussing general topics related to Couch.
3 posts Page 1 of 1
Hello Couches!
I follow the advice of cheesypoof and do new thread here.

It's about vote_poll, really works fine, however my client wants a little change.
Normal poll shows 10 replies as radio buttons and a button for voting - ok.

1. Could this change and no radio buttons and have 10 buttons for voting - one button for each answer? This can create more advanced layouts I think ...

2. How to send a simple email with name and phone number of the person who votes without making registration as a user.

I have a workable solution to the first problem.
But I think that it is not optimized, even stupid. I want to ask for a better solution:



Code: Select all
               <cms:show_votes 'test_poll' >   
                  <cms:each poll_options sep='\n'>
                     <cms:if "<cms:not_empty my_poll_options />" >   
                        <cms:form
                           masterpage=k_template_name
                           mode='edit'
                           page_id=k_page_id
                           anchor='0'
                           method='post'
                           >

                           <cms:if k_success>
                              <cms:dump />
                              <cms:db_persist_form
                                 test_poll=frm_poll
                              />
                              <cms:redirect page_to_redirect />
                           </cms:if>

                           <cms:input type='hidden' name='poll' value=k_count />
                                    <article>
                                        <div class="event_left">
                                            <div class="event_date"><cms:get "count_<cms:show k_count />" /></div>
                                            <div class="event_month"><cms:get "percent_<cms:show k_count />" />%</div>
                                        </div>
                                        <div class="event_detail">
                                            <h2 class="event_title"><cms:show item /></h2>       
                                           
               <input type="submit" name="submit" value="VOTE!" class="event_button ui button colored"/>
            
                                        </div>
                                    </article>
                        </cms:form>
                     </cms:if>                        
                  </cms:each>   
                           
               </cms:show_votes>



For the second task, however, no solution, please help!

Thank you all
Hi @orbital,

As you know, none of the regions of the 'votes' module mandate the use of any particular markup. You are free to use whatever suits you. The solution you used seems as good as any to me.

As alternative, I think, we could use only a single form where clicking one of those buttons would change the value of the vote. This will require use of JavaScript, something that is not my forte unfortunately.

If the JS gurus of our community are reading this thread, please chip in and propose a solution :)

With regards to the second question -
send a simple email with name and phone number of the person who votes without making registration as a user.
That would require defining some cms:inputs for the user to enter her info in. Submit it with the vote and then use it in the <cms:if k_success> condition to send the mail *before* redirecting the user.

Hope it helps.
Could you please try the following:
Code: Select all
<cms:show_votes 'test_poll'>
    <cms:form
        masterpage=k_template_name
        mode='edit'
        page_id=k_page_id
        anchor='0'
        method='post'
    >
        <cms:if k_success>
            <cms:db_persist_form
                test_poll=frm_poll
            />

            <cms:redirect page_to_redirect/>
        </cms:if>

        <cms:each poll_options sep='\n'>
            <cms:if "<cms:not_empty my_poll_options/>">
                <article>
                    <div class="event_left">
                        <div class="event_date"><cms:get "count_<cms:show k_count/>"/></div>
                        <div class="event_month"><cms:get "percent_<cms:show k_count/>"/>%</div>
                    </div>
                    <div class="event_detail">
                        <h2 class="event_title"><cms:show item/></h2>

                        <button class="event_button ui button colored" name="poll" type="submit" value="<cms:show k_count/>">VOTE!</button>
                    </div>
                </article>
            </cms:if>
        </cms:each>
    </cms:form>
</cms:show_votes>
3 posts Page 1 of 1

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 2 guests