Problems, need help? Have a tip or advice? Post it here.
12 posts Page 1 of 2
Hello All!
I am working with the Voting AddOn.
I want to only upvote (i.e. Like).
So the following code:
Code: Select all
<cms:form class="detail-banner-btn" masterpage='listing-detail.php' mode='edit' page_id="<cms:show k_page_id />" anchor='0' method='post'>
                                <cms:if k_success>
                                    <cms:db_persist_form
                                        my_vote=frm_vote
                                    />
                                    <cms:redirect k_page_link />
                                </cms:if>
                                <label>
                                    <cms:hide><cms:input type='radio' name='vote' /></cms:hide>
                                    <input type='radio' name='f_vote' value='1' />
                                    <a>
                                        <i class="fa fa-thumbs-o-up"></i> Like
                                    </a>
                                </label>
                                <!-- <input type="submit" name="submit" value="Vote"/> -->
                            </cms:form>


And to hide the Radio button and submit without button:
Code: Select all
<script type="text/javascript">
         $('input[type=radio]').hide();
         $(document).ready(function() {
            // make following action fire when radio button changes
            $('input[type=radio]').change(function(){
               // find the submit button and click it on the previous action
               $('input[type=submit]').click()
            });
         });
      </script>


Issue is:
I have a DBF in the footer too (embedded as footer.html). So I get the error multiple "k_nonce".
When I try to submit the vote (using above code) i get the error
ERROR: Tag "form" - page_id required


Except for the Rest of the code is as explained above i have followed the tutorial at: viewtopic.php?f=5&t=8133

vote.png
vote.png (114.18 KiB) Viewed 1812 times
Image
where innovation meets technology
Hi,

Let us go back to the basics and see if things are working as expected -

1. remove JS and see if the form works with the direct submit button
2. If not, remove the second DBF you have in the footer. Does that make the first form work?

This will give you clues for troubleshooting the matter further.

Hope it helps.
@KK Sir,

1. remove JS and see if the form works with the direct submit button

Yes it works although the k_nonce error is shown in the console

2. If not, remove the second DBF you have in the footer. Does that make the first form work?

Works with or with out the second DBF and the direct submit button, although the k_nonce error is shown in the console
Image
where innovation meets technology
I am actually trying to get the output like:

vote_final.png
vote_final.png (15.91 KiB) Viewed 1808 times


as seen in the picture:
1. if the Up and Down button could be changes to Like and Dislike button respectively and the radio buttons be gone
2. In place of the Vote (submit) button, only clicking the Like or Dislike button could register the vote
3. On refresh, the count_up and count_down could be displayed on the Like and Dislike buttons respectively

The code for the output as in picture above (without the css) is:
Code: Select all
<cms:form class="detail-banner-btn" masterpage=k_template_name mode='edit' page_id=k_page_id anchor='0' method='post'>
                                <cms:if k_success>
                                    <cms:db_persist_form
                                        my_vote=frm_vote
                                    />
                                    <cms:redirect k_page_link />
                                </cms:if>
                                <cms:input type='radio' name='vote' opt_values='Up=1 || Down=-1' /><br />
                                <input type="submit" name="submit" value="Vote"/>
                            </cms:form>
                            <cms:show_votes 'my_vote'>
                            <div class="detail-banner-btn">
                                <a href="#!">
                                    <i class="fa fa-thumbs-o-up"></i> Like (<cms:show count_up />)
                                </a>
                            </div>
                            <div class="detail-banner-btn">
                                <a href="#!">
                                    <i class="fa fa-thumbs-o-down"></i> Dislike (<cms:show count_down />)
                                </a>
                            </div>
                            </cms:show_votes>
Image
where innovation meets technology
BUMP :?:
Image
where innovation meets technology
genxcoders wrote: BUMP :?:

Hmm... maybe apply the same 2-buttons-submit solution (slightly modified) from your other topic viewtopic.php?f=4&t=11410 ?
@trendoman

Will give that a try and let you know.
Image
where innovation meets technology
@trendoman

This is the current code that I have.

Code: Select all
<cms:form class="detail-banner-btn" masterpage='business-listing.php' page_id="119" mode="edit" method="post" anchor="0">
                            <cms:if k_success>
                                <cms:if "<cms:gpc 'vote_up' />">
                                    <cms:db_persist_form my_vote='1' />
                                <cms:else />
                                    <cms:db_persist_form my_vote='-1' />
                                </cms:if>
                                <cmsredirect k_page_link />
                            </cms:if>
                            <button type="submit" name='vote_up' class="detail-banner-btn">
                                <i class="fa fa-thumbs-o-up"></i> Like
                            </button>
                            <button type="submit" name='vote_down' class="detail-banner-btn">
                                <i class="fa fa-thumbs-o-down"></i> Dislike
                            </button>
                        </cms:form>


my_vote is defined as:
Code: Select all
<cms:editable type='vote_updown' search_type='decimal' name='my_vote' label='Votes Casted' group='bl_noedit' />


no effect whatsoever.

any suggestions please?
Image
where innovation meets technology
Sure. Change your code to following working sample:
Code: Select all
<cms:form class="detail-banner-btn" masterpage='business-listing.php' page_id="119" mode="edit" method="post" anchor="0">
    <cms:if k_success>
        <cms:if "<cms:gpc 'vote_up' />">
            <cms:db_persist_form my_vote='1' />
        <cms:else_if "<cms:gpc 'vote_down' />" />
            <cms:db_persist_form my_vote='-1' />
        </cms:if>
        <cms:redirect k_page_link />
    </cms:if>
    <button type="submit" name='vote_up' class="detail-banner-btn" value="1">
        <i class="fa fa-thumbs-o-up"></i> Like
    </button>
    <button type="submit" name='vote_down' class="detail-banner-btn" value="1">
        <i class="fa fa-thumbs-o-down"></i> Dislike
    </button>
    <cms:input type='hidden' name='tmp' />
</cms:form>
@trendoman
Yes it is working now. The votes are being logged to the backend.
Now i tried the
Code: Select all
<cms:show coupt_up />

and
Code: Select all
<cms:show count_down />

But they do not work. What changes will be needed? Any :idea: ?

Even when i placed the
Code: Select all
<cms:dump />

and
Code: Select all
<cms:dump_all />

except for the
my_vote=-1

nothing else shows up, relating to the voting addon.
Image
where innovation meets technology
12 posts Page 1 of 2