Home
Download
Add-ons
Help
Forum
Organisation
Project
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
May 23, 2012, 07:40:52 PM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Interested in joining the WebsiteBaker team?
For more Information read
here
or on our
new website
.
155439
Posts in
21702
Topics by
7732
Members
Latest Member:
Smacki
WebsiteBaker Community Forum
English
Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
(Moderator:
Argos
)
New Snippet: AJAX Star Rating Snippet
Pages: [
1
]
Go Down
Author
Topic: New Snippet: AJAX Star Rating Snippet (Read 4739 times)
SourDough
Offline
Posts: 47
New Snippet: AJAX Star Rating Snippet
«
on:
August 27, 2008, 02:43:13 PM »
This was at the request of user Soki in thread
http://www.websitebaker2.org/forum/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
«
Last Edit: August 27, 2008, 04:00:11 PM by SourDough
»
Logged
soki
Offline
Posts: 4
Re: New Snippet: AJAX Star Rating Snippet
«
Reply #1 on:
August 28, 2008, 12:53:50 PM »
It's working fine.
Thanks a lot!
Sven
Logged
anjelo
Offline
Posts: 1
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
.
Hopefully I did. Thanks anyway!
Logged
erpe
Offline
Posts: 2077
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
stories about
be part of the Tutorials-Project
visit the jQuery-Showroom
SourDough
Offline
Posts: 47
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
Aaaarco
Offline
Posts: 25
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
webslaav
Offline
Posts: 2
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.
crnogorac081
AddOn Development
Offline
Posts: 1705
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
Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
crnogorac081
AddOn Development
Offline
Posts: 1705
Re: New Snippet: AJAX Star Rating Snippet
«
Reply #8 on:
July 31, 2009, 11:57:20 AM »
not working with wb 2.8 rc1
«
Last Edit: July 31, 2009, 11:59:50 AM by crnogorac081
»
Logged
Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
SourDough
Offline
Posts: 47
Re: New Snippet: AJAX Star Rating Snippet
«
Reply #9 on:
July 31, 2009, 02: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
crnogorac081
AddOn Development
Offline
Posts: 1705
Re: New Snippet: AJAX Star Rating Snippet
«
Reply #10 on:
July 31, 2009, 09:52:02 PM »
Hi Nick,
I downloaded and instaled the snippet from the first post (version 1.0). Then added
Code:
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, 09:57:47 PM by crnogorac081
»
Logged
Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
SourDough
Offline
Posts: 47
Re: New Snippet: AJAX Star Rating Snippet
«
Reply #11 on:
August 01, 2009, 07:58:24 PM »
This snippet works in conjunction with the module in my first post here:
http://www.websitebaker2.org/forum/index.php/topic,10332.0.html
. You need to install the module before AND the snippet for the snippet to work.
Nick
Logged
crnogorac081
AddOn Development
Offline
Posts: 1705
Re: New Snippet: AJAX Star Rating Snippet
«
Reply #12 on:
August 02, 2009, 12: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:
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
«
Last Edit: August 02, 2009, 04:54:56 PM by crnogorac081
»
Logged
Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
crnogorac081
AddOn Development
Offline
Posts: 1705
Re: New Snippet: AJAX Star Rating Snippet
«
Reply #13 on:
August 02, 2009, 05:08:18 PM »
I played a little with this snippet, and made a top rated list
This code should be included in include.php file just before
?>
tag
Code: (include.php)
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:
$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
Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
Pages: [
1
]
Go Up
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General Announcements
=> Security Announcements
=> Documentation
=> WebsiteBaker Website Showcase
=> Guest Area & Off-Topic
-----------------------------
English
-----------------------------
=> WebsiteBaker 2.9
===> Announcements
===> Help/Support
=====> Modules / Extensions
===> Suggestions
===> Software bugs
=> Help & Support
=> Modules
=> Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
=> jQuery
=> Templates, Menus & Design
=> WebsiteBaker Language Files
=> WebsiteBaker 2.x discussion
=> WebsiteBaker 3
=> Archive (posts up to 2007)
-----------------------------
Deutsch (German)
-----------------------------
=> Ankündigungen
=> WebsiteBaker 2.9
===> Ankündigungen
===> Hilfe/Support
=====> Module / Extensions
===> Vorschläge
===> Softwarefehler
===> Erfahrungs und Testberichte
=> Hilfe/Support
=> Module & Snippets
=> Templates & Design
=> Tutorials
=> jQuery
=> Diskussion über WB
=> Off-Topic
=> Archiv für Themen bis 2007
-----------------------------
Nederlands (Dutch)
-----------------------------
=> Aankondigingen
=> Hulp & Ondersteuning
=> Niet-Terzake (Off Topic)
-----------------------------
Francais (French)
-----------------------------
=> Help/Support
-----------------------------
Italiano (Italian)
-----------------------------
=> Help/Support
-----------------------------
Bakery (WB shop module)
-----------------------------
=> Bakery English
=> Bakery Deutsch
-----------------------------
KeepInTouch (Multi Contact Module)
-----------------------------
=> KeepInTouch English
=> KeepInTouch Deutsch
Loading...