Rating plugin

Rating plugin

Introduction

This plugin will allow you to add a rating option to any item on your site.

Release information

  • Latest version: 2.3
  • Release date: 2007/07/19
  • Download: version 2.3.0

Install

Usual install procedure.

Autotags

You can autotag any staticpage or story by adding the following text to a page:

[rating:id-tag]

Replace id-tag with any unique string. Unfortunately this means that when looking at the statistics page, you will not be able to see which item is rated in the top ten listing, as there is no way to pass the item unique id through the autotag system.

Hacking files

If you want to rate stories, there are only a couple of hacks to add rating support to the article function of Geeklog.

First, add the following code to lib-story.php around line 445:

        $article->set_var( 'edit_image',  '<img src="' . $editicon . '" alt="'
                . $LANG01[4] . '" title="' . $LANG01[4] . '" border="0">' );
    }


// RATINGS //

    if (function_exists('RATING_return_form'))
    {
        $article->set_var( 'rating',  RATING_return_form($A['sid'], 'story', 1, 5 ) );
    }

//RATINGS //


    // Need to convert text date/time to a timestamp
    $t = explode( ' ', $A['expire'] );
    $archiveDateTime = COM_convertDate2Timestamp( $t[0], $t[1] );

Then, add the text including the curly brackets to the template files featuredstorytext.thtml and storytext.thtml wherever you want the rating to be shown.

That should be it. In a similar way, you should be able to add rating functionality to the comments as well. You will need to add the tag to the comment/comments.thtml file in your theme(s). Then, add a similar call as above for stories to the file lib-comments.php in the system folder at about line 374, but changing "story" to "comment". Example code is below:

 

        $template->set_var( 'reply_link', $reply_link);


// RATINGS //

    global $_RATING_CONF;

    if ((function_exists('RATING_return_form')) &&
       (($_RATING_CONF['all_comments'] == '1') ||
        (in_array('comment', $_RATING_CONF['comments']))))
    {
        $template->set_var('rating',RATING_return_form($A['cid'],'comment',1,5) );
    }
    else
    {
        $template->set_var( 'rating', '');
    }

//RATINGS //


        // format title for display, must happen after reply_link is created
        $A['title'] = htmlspecialchars( $A['title'] );
        $A['title'] = str_replace( '$', '&#36;', $A['title'] );

|