Change Ranking Method

Hi i just want to ask for help, If i can change the ranking method to other else? Not in/out/pageviews rather than a custom field.?

My plan is to rank by a custom field example I will create a custom field "No of visits by alexa".
Then user or admin will put the number there, then ranking will sort by the custom field created.

Can you help me? Thanks.
 

Basti

Administrator
Staff member
You will need to create a plugin for that. I not integrated admin functions for this and not tested this, but should work just fine

1) Inside plugins folder create RankingMethods
2) In that folder create the following files
2.1) info.php with contents
Code:
<?php
$pluginname = "Ranking Methods";
$author = 'Basti';
$email = '';
$url = '#';
$install = 0;
$version = '1.0';
2.2) Let us overwrite globally the default ranking method. I used alexa as an example. change to whatever
- global_start.php with contents
Code:
$CONF['ranking_method'] = 'alexa';
2.2) Now that we have overwritten the default method, let us overwrite the rankings order
- rankings_order_by.php with following contents. replace my_column_name with your actual created column name and if you not use alexa in previous step, update here too.
Code:
    // Get the ranking method, default to alexa
    $ranking_method = isset($FORM['method']) ? $FORM['method'] : $CONF['ranking_method'];
    if (($ranking_method != 'pv') && ($ranking_method != 'in') && ($ranking_method != 'out') && ($ranking_method != 'alexa')) {
      $ranking_method = 'alexa';
    }

    // Make ORDER BY clause
    // Add your new column at the start
    // the stuff after that, is the default method as set in admin ( in/out/pv ) and is used in case of a tie on your new column
    $order_by = "my_column_name DESC, " . $this->rank_by($ranking_method_alt)." DESC, unq_{$ranking_method_alt}_overall DESC";
2.3) empty index.htm

3) Inside that plugin create folder "languages"
- In this folder create an empty english.php and empty index.htm
- In VL 1.5 this is still required, in soon to be released 1.6 not
 
Thank you, done doing as you said. So far it works. Thanks.
Upon doing the modification and all, its best that you have idea or technical terms in programming.
Fortunately, I am. I did analyze and all.
 

Basti

Administrator
Staff member
Yep, it works like the base methods in/out/pv ( just without the admin part )
The category viewing has nothing to do with order by ( what we modified ), its WHERE category = 'xx', so its independent of the code.

Order by orders results, category limits the results set
 
Top