phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

Star Rating


 
Search this topic... | Search MOD Requests... | Search Box
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Author Message
Holger
Board Member



Joined: 19 Jan 2009

Posts: 509
Location: Hanover


flag
PostPosted: Tue Nov 10, 2009 9:37 am 
Post subject: Star Rating

Hi,

I would like to have a sort of post rating, with stars.
Like here (Wordpress):
http://eldeby.cranespotter.se/

I have found a code doing this.
Instructions:
Code:
INSTALLATION:

=============================================================================
1. Make your table for the ratings in your db (you should be able to copy
and paste the following SQL)
=============================================================================
CREATE TABLE `ratings` (
`id` varchar(11) NOT NULL,
`total_votes` int(11) NOT NULL default 0,
`total_value` int(11) NOT NULL default 0,
`used_ips` longtext,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=3;


=============================================================================
2. Enter your specific info into _config-rating.php
=============================================================================
$dbhost = 'localhost';
$dbuser = '###';
$dbpass = '###';
$dbname = '###';
$tableName = 'ratings';
$rating_unitwidth = 30;


=============================================================================
3. Enter this line at the top of any page where you want
to have rating bars.
=============================================================================
<?php require('_drawrating.php'); ?>


=============================================================================
4. Point to the right Javascript and CSS files (you need
behavior.js, rating.js, and rating.css)
=============================================================================
<script type="text/javascript" language="javascript" src="js/behavior.js"></script>
<script type="text/javascript" language="javascript" src="js/rating.js"></script>
<link rel="stylesheet" type="text/css" href="css/rating.css" />

Remember to make sure to fix paths for the images as well. I kept behavior.js separate
from rating.js, because you can use it for other things!


=============================================================================
5. Drop the function wherever you want a rating bar to appear
=============================================================================
NOTE: As of version 1.2.1, use the echo statement! Also, if you use the static
parameter, you should always specify the 2nd parameter (number of units), even if
it is blank (which will default to 10 units)

<?php echo rating_bar('8'); ?> - 10 stars (default), ID of 8
<?php echo rating_bar('8xxa','5'); ?> - 5 stars, ID of 8xxa
<?php echo rating_bar('9a','5','static'); ?> - 5 stars, ID of 9a, static (non votable)
<?php echo rating_bar('9b',''); ?> - 10 stars, ID of 9b
<?php echo rating_bar('9c','8','static'); ?> - 8 stars, ID of 9c, static (non votable)


Ok, number 1-4 are clear I think.
Number 3 in includes/page_header.php?
Number 4 in overall_header.tpl?

Then I would like to use output:
Code:
<?php echo rating_bar('8xxa','5'); ?>


Two questions:
1) it should be possible to use a dynamic ID, something like the posts p-value?
Code:
<?php echo rating_bar('{p-value}','5'); ?>


2) how do I get the echo into viewtopic_body.tpl?

/Holger icon_redface.gif
Back to top
Display posts from previous:   
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0174 seconds using 15 queries. (SQL 0.0015 Parse 0.0005 Other 0.0155)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo