1
brutalicuss
Rating system in publisher module

Hi again

Is it possible to sort items by rating?
We have option to sort by hits and time, but not by rating
There is beautiful rating system in single item, but we cant use it for items sorting

Is it possible, or this module has such option, but im blind again

2
Mamba
Re: Rating system in publisher module
  • 2015/6/23 21:31

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


Yes, it is possible!

Do you want to do it yourself, or do you want to wait for the next version?

You can download the updated version from GitHub as a Zip file and test it. If I don't hear anything about issues/bugs, then I'll probably will release this version by July 1st.

To see what has changed, you can look here
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

3
brutalicuss
Re: Rating system in publisher module

Hi Mamba! Thank you very much! Im really glad that you want to improve publisher module.

But I have still trouble with the sorting

I mean that I need to sort items by many orders like time/votes/hits/comments in recent/latest list or some other way like publisher blocks - "recent publisher items" or any other possible way

I tried with the new correction in index.php/category.php to sort items by rating/votes but its seems to not working. Still sorting only by the time.

For hits and weight we have option in one publisher block, but for new features rating and votes (guess that is comments) we havent because these new functions are not included

Maybe I dont know how to use your editing or doing something wrong, and I will be thankful if you have time to explain me

4
Mamba
Re: Rating system in publisher module
  • 2015/6/24 10:30

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


Quote:
I tried with the new correction in index.php/category.php to sort items by rating/votes but its seems to not working. Still sorting only by the time.

You need to go to Preferences and select which way you want to sort. You'll have the five choices there:

- date
- title
- weight
- rating
- votes

If you just copied the news files over your existing test site, then you'll need to update the module to have the changes visible in Preferences.

Please note: this is still only for "test sites", and not production sites....
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

5
brutalicuss
Re: Rating system in publisher module

Yes, you are just great Mamba :))

I was adding the new lines in my files. Thats the fault !
Now, in new installation its working. And we can choose sort type of the list.

But I have still trouble (maybe personal) because I want to have more than one option for sorting, at the same time. There must be all sorting option. Now im trying to editing blocks php files to achieve this wishes :) Because after that I can clone the block and will have all sorting option :)

But if you plan to upload new publisher version and if you want this module to be just perfect, you should thinking about this option in "recent block" or some similar. Will be great to sort by all features - date/hits/rating/weight, even comments count.


6
Mamba
Re: Rating system in publisher module
  • 2015/6/25 14:08

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


Quote:
But I have still trouble (maybe personal) because I want to have more than one option for sorting, at the same time.

I am not sure if it makes much sense for Publisher and if is worth the effort. If you have 1,000 articles posted on the same date, and want to sort them by rating on that date, then it would make sense.

But if you have 2-10 articles on a given day, you can see it by just looking at them. Am I missing something?

But what we could do in the future is to add the sorting options on the front end, as it is already done in extGallery (see example) and WF-Downloads (see example). I believe that all XOOPS Module should have such a feature in the future....

However, I don't want to stop you from doing what you want to do. If you solve it and it's working, please submit the code for inclusion in the next version of Publisher...
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

7
brutalicuss
Re: Rating system in publisher module

Yes, you are right in principle - if we using publisher module for news, but if we makes article directory (in example) I think it is necessary, because you know some articles are important for the users months even years. In that case we really need of all sorting option.

Your example with extgallery and wt-download is very good, the same we have in weblinks also. Weblinks has all possible sorting option, not only in blocks (my favorite module ever)

Im already done new sorting in publisher blocks (its easy) based of your examples, BUT the sorting is not correct :) from 0 to 5, not 5 to 0. But im not programmer, just testing :)

8
Mamba
Re: Rating system in publisher module
  • 2015/6/25 18:17

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


Quote:
Yes, you are right in principle - if we using publisher module for news, but if we makes article directory (in example) I think it is necessary, because you know some articles are important for the users months even years. In that case we really need of all sorting option.

I am not sure, I understand it. Can you give me a concrete example?
Let's say, I have 200 articles, 20 per year, and one article from 7 year ago is important.

In my thinking, I just give it the highest weight, so when sorted by weight, it will come up as first.

If the users want to vote for it, then they rate it, and based on the rating, the highest rated articles will come up first.

What am I missing?

Quote:
Im already done new sorting in publisher blocks (its easy) based of your examples, BUT the sorting is not correct :) from 0 to 5, not 5 to 0. But im not programmer, just testing

You probably have to change from "ASC" to "DESC"

Show your code and maybe somebody could help...
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

9
brutalicuss
Re: Rating system in publisher module

Quote:

If the users want to vote for it, then they rate it, and based on the rating, the highest rated articles will come up first.


Thats I mean Mamba, users will define which article is important, and if we havent rating sort system this will be impossible, isnt it
But we must have other sorting option also, like time, hits and etc. I think it is normal for any publisher site. Just option: "show most rated", "show most visited" "votes", "comments"..etc These are just features. Good features!

As for "ASC" to "DESC" sorting I tried everything :) Something buggy, and I really cant, because im not programmer

In this context, I tried to set your fix to sort by ASC not DESC and nothing happens - order still was by DESC. You shouldnt upload this before closely testing I think

10
brutalicuss
Re: Rating system in publisher module

lol I did it

But this is not professional work and I think shouldnt use in official ver.
This is only for who wants to have all sorting option like me.

language/english/modinfo.php
add bellow:
define("_MI_PUBLISHER_ORDERBY_RATING","Rating DESC");
define("_MI_PUBLISHER_ORDERBY_VOTES","Votes DESC");
define("_MI_PUBLISHER_ORDERBY_COMMENTS","COMMENTS DESC");


xoops_version.php

replace:
$modversion['config'][$i]['options'] = array(_MI_PUBLISHER_PUBLISHED => _PUBLISHER_STATUS_PUBLISHED,
                                             
_MI_PUBLISHER_OFFLINE => _PUBLISHER_STATUS_OFFLINE,
                                             
_MI_PUBLISHER_SUBMITTED => _PUBLISHER_STATUS_SUBMITTED,
                                             
_MI_PUBLISHER_REJECTED => _PUBLISHER_STATUS_REJECTED);


with:
$modversion['config'][] = array(
    
'name'        => 'format_order_by',
    
'title'       => '_MI_PUBLISHER_ORDERBY',
    
'description' => '_MI_PUBLISHER_ORDERBYDSC',
    
'formtype'    => 'select',
    
'valuetype'   => 'text',
    
'options'     => array(
        
_MI_PUBLISHER_ORDERBY_TITLE  => 'title',
        
_MI_PUBLISHER_ORDERBY_DATE   => 'date',
        
_MI_PUBLISHER_ORDERBY_RATING => 'rating',
        
_MI_PUBLISHER_ORDERBY_VOTES  => 'votes',
        
_MI_PUBLISHER_ORDERBY_COMMENTS  => 'comments',
        
_MI_PUBLISHER_ORDERBY_WEIGHT => 'weight'),
    
'default'     => 'date',
    
'category'    => 'format'
);



item.php

replace:
switch ($publisher->getConfig('format_order_by')) {
    case 
'title' :
        
$sort 'title';
        
$order 'ASC';
        break;

    case 
'date' :
        
$sort 'datesub';
        
$order 'DESC';
        break;

    default :
        
$sort 'weight';
        
$order 'ASC';
        break;
}


with:
switch ($publisher->getConfig('format_order_by')) {
    case 
'title':
        
$sort  'title';
        
$order 'ASC';
        break;

    case 
'date':
        
$sort  'datesub';
        
$order 'DESC';
        break;

    case 
'rating' :
        
$sort 'rating';
        
$order 'DESC';
        break;
        
    case 
'votes' :
        
$sort 'votes';
        
$order 'DESC';
        break;
        
    case 
'comments' :
        
$sort 'comments';
        
$order 'DESC';
        break;

    default :
        
$sort  'weight';
        
$order 'ASC';
        break;
}




index.php

replace:
switch ($publisher->getConfig('format_order_by')) {
        case 
'title' :
            
$sort 'title';
            
$order 'ASC';
            break;

        case 
'date' :
            
$sort 'datesub';
            
$order 'DESC';
            break;

        default :
            
$sort 'weight';
            
$order 'ASC';
            break;
    }


with:
switch ($publisher->getConfig('format_order_by')) {
        case 
'title':
            
$sort  'title';
            
$order 'ASC';
            break;

        case 
'date':
            
$sort  'datesub';
            
$order 'DESC';
            break;

        case 
'rating' :
            
$sort 'rating';
            
$order 'DESC';
            break;
            
        case 
'votes' :
            
$sort 'votes';
            
$order 'DESC';
            break;
            
        case 
'comments' :
            
$sort 'comments';
            
$order 'DESC';
            break;
        default:
            
$sort  'weight';
            
$order 'ASC';
            break;
    }



category.php

replace:
switch ($publisher->getConfig('format_order_by')) {
    case 
'title' :
        
$sort 'title';
        
$order 'ASC';
        break;

    case 
'date' :
        
$sort 'datesub';
        
$order 'DESC';
        break;

    default :
        
$sort 'weight';
        
$order 'ASC';
        break;
}


with:
switch ($publisher->getConfig('format_order_by')) {
    case 
'title' :
        
$sort  'title';
        
$order 'ASC';
        break;

    case 
'date' :
        
$sort  'datesub';
        
$order 'DESC';
        break;

    case 
'rating' :
        
$sort 'rating';
        
$order 'DESC';
        break;

    case 
'votes' :
        
$sort 'votes';
        
$order 'DESC';
        break;
            case 
'comments' :
        
$sort 'comments';
        
$order 'DESC';
        break;

    default:
        
$sort  'weight';
        
$order 'ASC';
        break;
}



BLOCKS
blocks/item_new.php

replace:
$item['title'] = $itemsObj[$i]->title();

            if (
$sort == "datesub") {
                
$item['new'] = $itemsObj[$i]->datesub();
            } elseif (
$sort == "counter") {
                
$item['new'] = $itemsObj[$i]->counter();
            } elseif (
$sort == "weight") {
                
$item['new'] = $itemsObj[$i]->weight();
            }

            
$block['newitems'][] = $item;



with:
$item['title'] = $itemsObj[$i]->title();

            if (
$sort == "datesub") {
                
$item['new'] = $itemsObj[$i]->datesub();
            } elseif (
$sort == "counter") {
                
$item['new'] = $itemsObj[$i]->counter();
            } elseif (
$sort == "weight") {
                
$item['new'] = $itemsObj[$i]->weight();
                } elseif (
$sort == "rating") {
                
$item['new'] = $itemsObj[$i]->rating();
                } elseif (
$sort == "votes") {
                
$item['new'] = $itemsObj[$i]->votes();
                }
                elseif (
$sort == "comments") {
                
$item['new'] = $itemsObj[$i]->comments();
                }
            
            
$block['newitems'][] = $item;



replace:
$orderEle->addOptionArray(array(
                                  
'datesub' => _MB_PUBLISHER_DATE,
                                  
'counter' => _MB_PUBLISHER_HITS,
                                  
'weight'  => _MB_PUBLISHER_WEIGHT,
                              ));


with:
$orderEle->addOptionArray(array(
                                  
'datesub' => _MB_PUBLISHER_DATE,
                                  
'counter' => _MB_PUBLISHER_HITS,
                                  
'weight'  => _MB_PUBLISHER_WEIGHT,
                                  
'rating'  => _MI_PUBLISHER_ORDERBY_RATING,
                                  
'votes'   => _MI_PUBLISHER_ORDERBY_VOTES,
                                  
'comments'   => _MI_PUBLISHER_ORDERBY_COMMENTS,
                              ));


include/functions.php

replace:
function publisherGetOrderBy($sort)
{
    if (
$sort == "datesub") {
        return 
"DESC";
    } elseif (
$sort == "counter") {
        return 
"DESC";
    } elseif (
$sort == "weight") {
        return 
"ASC";
    }

    return 
null;
}


with:
function publisherGetOrderBy($sort)
{
    if (
$sort == "datesub") {
        return 
"DESC";
    } elseif (
$sort == "counter") {
        return 
"DESC";
    } elseif (
$sort == "weight") {
        return 
"ASC";
    }
    elseif (
$sort == "votes") {
        return 
"DESC";
    }
    elseif (
$sort == "rating") {
        return 
"DESC";
    }
        elseif (
$sort == "comments") {
        return 
"DESC";
    }

    return 
null;
}



Thas all!
Working well for both: starting page and block "recent items list"
If you want to have more than one option in this block, just clone it
If you want to have these sortings on whole or many pages, just use cloned block in dummy module

10x Mamba, It would not happen without you

Login

Who's Online

388 user(s) are online (221 user(s) are browsing Support Forums)


Members: 0


Guests: 388


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits