Welcome to Geeklog, Anonymous Saturday, November 30 2024 @ 10:41 pm EST

Geeklog Forums

How to implement rating feature in a plugin


Status: offline

::Ben

Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
I try to implement rating feature in paypal plugin to allow users to rate products and give review.

Integration is simple, and involves calling just one function that will return the HTML to incorporate into paypal plugin page.
The call is something like :

Text Formatted Code
/* start rating code */
    if (function_exists('RATING_display_rating'))
    {
        $product->set_var('rating',  RATING_display_rating('paypal_' . $A['id'], 'paypal', $A['id'], 1, 5, CONST_FLAG_DEFAULT_RATING ) );
    }

/* end rating code */


where $A['id'] is my product id. I also need to customise my template. This simply require that I add {rating} wherever I wanted to have a rating appear in my products page.

Now I need to know how to handle some $_RATING_CONF?

Text Formatted Code

/*
* Current supported types include staticpage, comment, story & autotagged
* If you have a new type that you would like to link properly and display
* a correct title use the following user sample below.  For a new type you
* would change in the $_RATING_CONF variable the text "user" to what ever
* you called your type.  A sample user type is included below.
*/
// For paypal plugin
$_RATING_CONF['rating_type_paypal'] = 'paypal';
$_RATING_CONF['rating_type_paypal_url'] = '/' . $_PAY_CONF['paypal_folder'] . '/product_detail.php?product=';
$_RATING_CONF['rating_type_paypal_title']  = "SELECT name FROM " . $_TABLES['paypal_products'] . " WHERE id=";


If I add these $_RATING_CONF in the plugins/rating/config.php file it is working... but do I need to update the rating plugin to allow the paypal plugin to work with this feature.

Does another way exists?

::Ben

I'm available to customise your themes or plugins for your Geeklog CMS
 Quote

Status: offline

suprsidr

Forum User
Full Member
Registered: 12/29/04
Posts: 555
Location:Champaign, Illinois
If $_RATING_CONF is global, you should be able to add those anywhere at runtime.

-s
FlashYourWeb and Your Gallery with the E2 XML Media Player for Gallery2 - http://www.flashyourweb.com
 Quote

Status: offline

::Ben

Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
Hi Wayne,

I do not find the way do assign my values in the paypal plugin and make them available for the rating plugin

Text Formatted Code
// For paypal plugin
global $_RATING_CONF;
$_RATING_CONF['rating_type_paypal'] = 'paypal';
$_RATING_CONF['rating_type_paypal_url'] = '/' . $_PAY_CONF['paypal_folder'] . '/product_detail.php?product=';
$_RATING_CONF['rating_type_paypal_title']  = "SELECT name FROM " . $_TABLES['paypal_products'] . " WHERE id=";


:helpme:

::Ben
I'm available to customise your themes or plugins for your Geeklog CMS
 Quote

Status: offline

Laugh

Site Admin
Admin
Registered: 09/27/05
Posts: 1470
Location:Canada
Hey Cordiste,

In the upcoming release the new integration will not require any file modificaitons beyond adding the rating template variable to theme files. As long as the plugin which needs ratings, supports the appropriate properties from the function plugin_getiteminfo_xxxx (see the staticpage plugin for example). I haven't completely finish writing this part yet for the rating plugin but it should work.

For now if you feel you need to (to make it easier for users) why don't you add the required code for the paypal plugin to the rating plugin version 2.3.0 and bump it to version 2.3.1?

Tom
One of the Geeklog Core Developers.
 Quote

Status: offline

::Ben

Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
Tom,

Ok I will make a 2.3.1 release. I fixed few bugs in the admin area and changed the color of the stars. I installed the plugin on geeklog.fr to allow stories rating as a demo.

I also added :

Text Formatted Code
function plugin_templatesetvars_rating($templatename, &$template)
{

    switch ($templatename) {

    case 'storytext':
    case 'featuredstorytext':
    case 'archivestorytext':
        $sid = $template->get_var('story_id');
        $template->set_var('rating',  RATING_display_rating($sid, 'story', $sid, 1, 5, CONST_FLAG_RATING_AS_STARS ) );
        break;
    }
}


Like this, the only things users need to make is adding the rating template variable to theme files.

::Ben
I'm available to customise your themes or plugins for your Geeklog CMS
 Quote

All times are EST. The time is now 10:41 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content