Forum for discussing general topics related to Couch.
3 posts Page 1 of 1
Hi there. I am working on my own blog where user can rate the post and vote other products. But I am having trouble with both the star rating and voting. Both the scripts works with the last post but it doesn't work with the previous posts. And also for the star rating I can only rate up-to 4 stars. 5th star is not working. Please help me. Here is my script.
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Rate'>
    <cms:editable type='vote_updown' search_type='decimal' name='my_vote' label='Votes Casted' />
    <cms:editable type='vote_stars' search_type='decimal' allow_zero_stars='0' name='my_stars' />
</cms:template>
<!DOCTYPE html>
<html>
<head>
    <title>Rate</title>
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css">
    <link href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
    <style>
        .rating {
      float:left;
    }
    /* :not(:checked) is a filter, so that browsers that don’t support :checked don’t
      follow these rules. Every browser that supports :checked also supports :not(), so
      it doesn’t make the test unnecessarily selective */
    .rating:not(:checked) > input {
        position:absolute;
        top:-9999px;
        clip:rect(0,0,0,0);
    }
    .rating:not(:checked) > label {
        float:right;
        width:1em;
        /* padding:0 .1em; */
        overflow:hidden;
        white-space:nowrap;
        cursor:pointer;
        font-size:300%;
        /* line-height:1.2; */
        color:#ddd;
    }
    .rating:not(:checked) > label:before {
        content: '★ ';
    }
    .rating > input:checked ~ label {
        color: dodgerblue;
    }
    .rating:not(:checked) > label:hover,
    .rating:not(:checked) > label:hover ~ label {
        color: dodgerblue;
    }
    .rating > input:checked + label:hover,
    .rating > input:checked + label:hover ~ label,
    .rating > input:checked ~ label:hover,
    .rating > input:checked ~ label:hover ~ label,
    .rating > label:hover ~ input:checked ~ label {
        color: dodgerblue;
    }
    .rating > label:active {
        position:relative;
        top:2px;
        left:2px;
    }
</style>
</head>
<body>
    <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 my_stars=frm_stars />
            <cms:redirect k_page_link />
        </cms:if>
        <div class="rating">
            <cms:input type='radio' id="star" name="stars" opt_values='5 | 4 | 3 | 2 | 1' />
            <input type="submit" name="submit" value="Vote" />
        </div>
    </cms:form>
    <cms:form masterpage=k_template_name mode='edit' page_id=k_page_id anchor='0' method='post'>
        <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:if k_success>
                <cms:set_flash name='success_msg' value="Thanks for your feedback!" />
                <cms:redirect k_page_link />
            </cms:if>
        </cms:if>
        <button type="submit" name='vote_up' class="detail-banner-btn" value="1">
            <i class="fa fa-thumbs-o-up"></i> Like (<cms:show_votes 'my_vote'>
                <cms:show count_up />
            </cms:show_votes>)
        </button>
        <button type="submit" name='vote_down' class="detail-banner-btn" value="1">
            <i class="fa fa-thumbs-o-down"></i> Dislike (<cms:show_votes 'my_vote'>
                <cms:show count_down />
            </cms:show_votes>)
        </button>
        <cms:input type='hidden' name='tmp' />
    </cms:form>
    <cms:show_votes 'my_stars'>
        <br />
        <p>
            <cms:dump />
        </p>
    </cms:show_votes>
    <cms:show_votes 'my_vote'>
        <cms:dump />
    </cms:show_votes>
</body>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<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>
</html>
<?php COUCH::invoke(); ?>


Thank you for your help and sorry for my english.
Can anyone help me?
upadesh wrote: Can anyone help me?

I can, but I did not find you in my list of donators, so wait for @KK to respond when he has extra free time.
3 posts Page 1 of 1
cron