PageRank
How can I choose the most popular page(s), topic(s), product(s) on the site?
You can use the PageRank tool to allow users to vote on whether they like anything that's attached to a single page. With modifications, this could be extended to multiple items on a page.
Description
Plug-in for page ranking system.
Notes
This is a basic page-ranking system. It could use some improvements graphically, but basically it allows users to vote (default 1-5) on a page. It only requires CSS, no JavaScript is used.
Security Note until PmWiki comes out with "insert" permissions, this recipe can add information to pages regardless of whether the user has edit/read permissions. Only enable this recipe on pages you wish rankings to be on, and note that the only "security" feature is the default that requires users are logged in. Later this recipe will require "insert" permissions.
Installation
- Place pagerankstars.phpΔ into your pmwiki/cookbook folder
- Place into your pub/images folder
- add this line to config.php:
include_once("$FarmD/cookbook/pagerankstars.php");
Usage
Votes by login
The default behavior of the script is to track votes by login. This means that if a user votes again, it changes their original vote.
To rate a page by login
If you would like to use the PageRank in a specific group, add the following to GroupHeader or to GroupFooter:
(:if authid :) (:PageRankStars:) (:ifend:)
To allow votes regardless of login
This behavior accumulates votes, regardless of whether the user is logged in or not. If a user votes again, it's counted as an additional vote.
- in config.php, and BEFORE including star_ratings.php:
$PRS_Vote['exclusive'] = false;
- Add to GroupHeader or GroupFooter:
(:PageRankStars:)
To display the page rating
This displays the page rating only if the page is rated, and is added to the GroupHeader or GroupFooter. A visual star interpretation will come in a later release.
(:if ! equal {*$RatingAverage} "" :) Rating: {*$RatingAverage} / 5 ({*$RatingCount} votes) (:ifend:)
Options
These are the options enabled by the recipe so far:
change the star image
You may use other images than stars, or different star images. The "empty" image should be on top, the "filled" image should be on the bottom, thus the image should be half as wide as it is high. See star_rating.gif for an example. Use the new image by changing the following settings:
- Add to config.php
$PRS_Vote['vote_image_url'] = "path/to/image/image.gif"; $xesVote['star_width'] = ##; // put the width of your image here
change the range for ratings
You may change the number of stars or the range of the vote.
$PRS_Vote['max_stars'] = 4;
list the user votes on the page
The following will tally the user votes visibly. Due to a bug in PmWiki, the votes had to be placed at the top of the page being edited, so you will want to use GroupHeader to display the voting results.
$PRS_Vote['hidden'] = false;
Release Notes
- 2006-11-09
- Version 0.1 released - adapted from tutorials at komodomedia.com, a website that no longer exists (2014). Uncertain of original licensing. XES contributions CC0 (text) & GPL2 (code) if possible.
- 2006-11-12
- Version 0.2 released - bug fixes, documentation corrections
- 2006-11-12
- Version 0.3 released - another bug fix
- 2006-12-02
- Version 0.4 released - now checks rating entered for numeral.
To-Do
- Display stars for current vote.
- Allow recipe to automatically use correct tense on number of votes cast
- Allow recipe to use radio buttons instead of an image
- Test the unhidden feature and the ability to change the number of stars
- Add in ability for aye/nay/abstain voting for organizations
Comments
I like the pagerank recipe, but I would like to limit the number of times a person could rate a page to once. Also, I would like to display a list of the top ranked Authors based on reader rankings. Am I a dreamer?
Scott Ott -> mailto:scottott [snail] scrappleface [period] com
$PRS_Vote['exclusive'] = true;
for people to vote only once. This works best if you require people to log in to vote, of course, otherwise there's no good way to track whether someone has already voted.Displaying the top rated author would depend on how you have the website configured, and is probably a question more suited for the user list or IRC channel. See MailingLists about the mailing list and for IRC; we're on irc.freenode.net #pmwiki. For questions (generally free) and (paid) custom programming, I can be contacted personally on AIM or Skype at EclecticTLLC. XES March 01, 2007, at 09:03 PM
See Also
Contributors
User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.