WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • New Snippet: AJAX Star Rating Snippet
  • Print
Pages: [1]   Go Down

Author Topic: New Snippet: AJAX Star Rating Snippet  (Read 17434 times)

SourDough

  • Guest
New Snippet: AJAX Star Rating Snippet
« on: August 27, 2008, 03:43:13 PM »
This was at the request of user Soki in thread https://forum.WebsiteBaker.org/index.php/topic,10332.msg64477.html#msg64477. 

This snippet provides a way to display just one of the questions/ratings from the AJAX Star Rating module on a page type code, or from the template index.php file.  This snippet does not allow voting to take place, it is for display purposes only.  If there is enough interest, I can rewrite to allow voting. 

There is a readme included, but basic usage follows:

From template index.php:
<?php pullRatingSnip(); ?>

From a code module:
pullRatingSnip();

For a more customized output, you can pass over serveral parameters to the function explained below.

<?php pullRatingSnip($question_id,$showfive,$showperc,$showtotal,$showdetail); ?>

Options:
//question_id    id of the question (defaults to 1)
//showfive       shows how many votes out of five, 0 for no, 1 for yes (default yes)
//showperc       shows vote percentage, 0 for no, 1 for yes (default yes)
//showtotal      shows total votes, 0 for no, 1 for yes (default yes)
//showdetail         whether to show question detail, 0 for no, 1 for yes (default no)


Hope this is useful.

Nick

 

[gelöscht durch Administrator]
« Last Edit: August 27, 2008, 05:00:11 PM by SourDough »
Logged

soki

  • Guest
Re: New Snippet: AJAX Star Rating Snippet
« Reply #1 on: August 28, 2008, 01:53:50 PM »
It's working fine.
Thanks a lot!

Sven
Logged

anjelo

  • Guest
Re: New Snippet: AJAX Star Rating Snippet
« Reply #2 on: December 09, 2008, 07:10:29 PM »
Hey this is THE solution I was looking for so long. I didn't know if I was going to find it till the end of the new year in. :mrgreen:

Hopefully I did. Thanks anyway!
Logged

erpe0812

  • Guest
Re: New Snippet: AJAX Star Rating Snippet
« Reply #3 on: December 09, 2008, 08:17:48 PM »
There is another one listed at AMASP.

rgds

erpe
« Last Edit: December 29, 2008, 02:04:03 PM by erpe »
Logged

SourDough

  • Guest
Re: New Snippet: AJAX Star Rating Snippet
« Reply #4 on: December 10, 2008, 06:33:55 PM »
FYI, this snippet only works with the original version of the AJAX Star Rating, not with the "improved" version by Johnp.

Nick

Logged

Offline Vlob

  • Posts: 106
Re: New Snippet: AJAX Star Rating Snippet
« Reply #5 on: March 13, 2009, 09:06:00 AM »
anyone already made a droplet from the snippet?  would be very handy
Logged

Offline webslaav

  • Posts: 4
  • Gender: Male
Re: New Snippet: AJAX Star Rating Snippet
« Reply #6 on: March 18, 2009, 02:27:38 PM »
Love the snippet! Here's a new question for you all:
I have a bunch of pages and all can be rated.
Now, on the homepage I want links to the 5 pages with the highest scores. Just the highest, not through difficult math of how many people voted versus scores..just plain scores.

Can anyone help?
Regards,
Alex
Logged
For a moment, nothing happened. Then, after a second or so, nothing continued to happen.

Offline crnogorac081

  • Posts: 2161
  • Gender: Male
Re: New Snippet: AJAX Star Rating Snippet
« Reply #7 on: March 18, 2009, 02:46:39 PM »
I created  a new page, and in code module inserted pullRatingSnip(); and nothing happened ??

what am I doing wrong?
Logged
Web developer

Offline crnogorac081

  • Posts: 2161
  • Gender: Male
Re: New Snippet: AJAX Star Rating Snippet
« Reply #8 on: July 31, 2009, 12:57:20 PM »
not working with wb 2.8 rc1 :(
« Last Edit: July 31, 2009, 12:59:50 PM by crnogorac081 »
Logged
Web developer

SourDough

  • Guest
Re: New Snippet: AJAX Star Rating Snippet
« Reply #9 on: July 31, 2009, 03:36:30 PM »
Which version of Ajax Star Rating are you using?  What errors are you seeing?  Set error reporting to E_ALL.  Additionally, this snippet was written by me to work with the original release of this module.  I suspect you are using the version of the module re-released by JohnP (aka cnwb).

Nick
Logged

Offline crnogorac081

  • Posts: 2161
  • Gender: Male
Re: New Snippet: AJAX Star Rating Snippet
« Reply #10 on: July 31, 2009, 10:52:02 PM »
Hi Nick,

I downloaded and instaled the snippet from the first post (version 1.0). Then added
Code: [Select]
pullRatingSnip();
in a code section on some page. Here is error:

Fatal error: Call to a member function fetchRow() on a non-object in I:\WebsiteBaker Portable1_2\htdocs\inf\modules\AJAX_Star_Rating_Snippet\include.php on line 36

al best,
ivan
« Last Edit: July 31, 2009, 10:57:47 PM by crnogorac081 »
Logged
Web developer

SourDough

  • Guest
Re: New Snippet: AJAX Star Rating Snippet
« Reply #11 on: August 01, 2009, 08:58:24 PM »
This snippet works in conjunction with the module in my first post here:  https://forum.WebsiteBaker.org/index.php/topic,10332.0.html.  You need to install the module before AND the snippet for the snippet to work. 

Nick
Logged

Offline crnogorac081

  • Posts: 2161
  • Gender: Male
Re: New Snippet: AJAX Star Rating Snippet
« Reply #12 on: August 02, 2009, 01:44:39 AM »
Hi,

just followed your instructions and page rating was working, but the snippet didn't. I examined the code from the snipped as Error I mentioned above appeared again, and find that it was wrong table name to call:

Code: [Select]
mod_ajaxstarratting_question
mod_ajaxstarratting_rating

instead

mod_ajaxsurvey_question
mod_ajaxsurvey_rating

It must be some older version :)

Also in page rating, I added an extra line in backend (see attached picture) for Id (it will be handy if you have much questions to rate, when you call the snippet..)

I also zipped "fixed" page rating (includes new rating_functions.ph p ), and the snippet..

cheers




[gelöscht durch Administrator]
« Last Edit: August 02, 2009, 05:54:56 PM by crnogorac081 »
Logged
Web developer

Offline crnogorac081

  • Posts: 2161
  • Gender: Male
Re: New Snippet: AJAX Star Rating Snippet
« Reply #13 on: August 02, 2009, 06:08:18 PM »
I played a little with this snippet, and made a top rated list  :-D

This code should be included in include.php file just before ?> tag
Code: (include.php) [Select]
function Show_Top_Rating($count = 5, $title = "Top rated:", $show_title = 1, $show_totals = 0, $ShowRatingStars = 1, $ShowOutOfFive = 1, $ShowRating = 1, $ShowVotes = 1 ) {
    global $database;
    $tbl_counter = TABLE_PREFIX ."mod_ajaxsurvey_question";
    $tbl_pages = TABLE_PREFIX ."pages";
    $pagelist = $database->query("SELECT sum(question_id) as total, r.page_id, p.page_title, p.menu_title, p.link, question_id as question
        FROM $tbl_counter r
        INNER JOIN $tbl_pages p on (p.page_id = r.page_id)
        GROUP BY page_id
        ORDER BY total ASC");
    $inner_count = 0;
    if ($pagelist->numRows() > 0){
        echo "<div class=\"ajaxTopRatingTitle\"><h3>$title</h3></div><div class=\"ajaxTopRatingBox\"><ul>";
        while(($res = $pagelist->fetchRow()) && ($inner_count++ < $count)) {
   
        if ($ShowOutOfFive == 1) { $OutOfFiveEcho = ' ,Rated <span id="outOfFive_'.$res['question'].'" class="out5Class">'.outOfFiveSnip($res['question']).'</span>/5'; } else { $OutOfFiveEcho = ''; }
        if ($ShowVotes == 1) { $ShowVotesEcho = ' ,<span id="percentage_'.$res['question'].'" class="percentClass">'.getVotesSnip($res['question']).'</span>'; } else { $ShowVotesEcho = ''; }
        if ($ShowRating == 1) { $ShowRatingEcho = ' (<span id="showvotes_'.$res['question'].'" class="votesClass">'.getRatingSnip($res['question']).'</span>)'; } else { $ShowRatingEcho = ''; }
        if ($ShowRatingStars == 1) { $ShowRatingStarsEcho = pullRating($res['question']); } else { $ShowRatingStarsEcho = ''; }

            if ($show_title == 1) {
                $TopRatedTitle = showQuestionTitle($res['question']); }           
            else if ( $show_title == 2) {
            $TopRatedTitle = $res['menu_title']; }
            else if ( $show_title == 3) {
            $TopRatedTitle = $res['page_title']; }


            echo "<li><a href=\"".page_link($res['link'])."\"";
            echo ">".$TopRatedTitle.$ShowRatingStarsEcho.$OutOfFiveEcho.$ShowRatingEcho.$ShowVotesEcho."</a></li>" ;
        }
        echo "</ul></div>";
    }
}


You can call the snippet with simple Show_Top_Rating(); or advanced call:  Show_Top_Rating(5,"Top rated pages:",2,1,1,1,1);

the parametars in snippet are:

Code: [Select]
$count = 5                    ---- shows number of items in list
$title = "Top rated:"       ---- Title text
$show_title = 1              ---- Shows title for list item: 1 = Question title, 2 = Menu title, 3 = Page title
$ShowRatingStars = 1      ---- Displays stars
$ShowOutOfFive = 1        ---  Shows: Rated 5/5
$ShowRating = 1             ---- Shows: (100%)
$ShowVotes = 1             ----  Shows: 1 time vodet

Also there are two css classes: ajaxTopRatingTitle and ajaxTopRatingBox which you can style in your template css file..

cheers
Logged
Web developer

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • New Snippet: AJAX Star Rating Snippet
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2