Something wrong with ordering and the params

7 months 2 weeks ago #1933
Topic Author
Theodore Hildebrandt's Avatar
Posts: 6
Something wrong with ordering and the params

I have set "Title" as the ordering in both the System parameters and the Competition parameters, and yet it continues to use "votes" as the ordering parameter instead.

I put in some debug code to see what it is pulling into $this->competition->getParams(); (Line 76 of models/competition.php), and I get this:

[participants_default_order] => votes
[participants_default_order_dirn] => DESC

I have set it to title ascending in both places, so these should not be the values coming in.

In the database, this is the value in the params field for the competition:

{"competition_image":"","app_forms_per_competition":"","competition_apps_approve":"","competition_multiple_photos":"0","competition_multiple_photos_limit":"2","competition_app_forms_user":"0","competition_entry_form_ip":"0","enable_rating":"","vote_start_date":"2018-12-01 17:04:00","vote_end_date":"2019-03-31 16:04:00","competition_show_votes":"","competition_allowed_votes":"20","cvote_frequency":"","cvote_frequency_custom":"","cvote_frequency_mode":"","participant_allowed_votes":"1","vote_frequency":"43200","vote_frequency_custom":"","vote_frequency_mode":"days","count_past_votes":"1","vote_own_participant":"","vote_check_ip":"","vote_check_ip_user_agent":"1","vote_check_cookie":"1","cookie_expire_time":"","competition_enable_aup":"","participants_show_competition_title":"1","participants_show_competition_description":"1","participants_show_start_countdown":"","participants_show_end_countdown":"","participants_show_vote_start_countdown":"","participants_show_vote_end_countdown":"","participants_show_vote":"1","participants_show_share":"1","participants_play_video":"1","competition_show_participants":"1","participants_show_total":"","participants_show_submitter":"","participants_submitter_title":"","participants_items_per_row":"4","participants_items_per_page":"32","participants_title_length":"","participants_custom_field":"13","participants_field_length":"365","participants_items_in_result":"","participants_sorting_field":"0","participants_items_in_sorting_result":"3","participants_show_filter_search":"","participants_show_sort_filter":"","participants_sort_filter_options":["title"],"participants_show_pagination_limit":"","participants_pagination_limit_options":"","participants_default_order":"title","participants_default_order_dirn":"ASC","participants_show_pagination":"","participants_show_pagination_results":"","competitions_show_competition_image":"","competitions_show_competition_description":"","competitions_show_competition_info":"","competitions_show_competition_type":"","competitions_show_competition_category":"","competitions_competition_link_category":"","competitions_show_competition_status":"","competitions_show_competition_created_time":"","competitions_show_competition_start_time":"","competitions_show_competition_end_time":"","competitions_show_competition_voting_start_time":"","competitions_show_competition_voting_end_time":"","participant_show_participant_title":"1","participant_show_competition_title":"0","participant_link_competition_title":"0","participant_show_submitter":"0","participant_submitter_name":"name","participant_link_submitter":"1","participant_show_share":"1","participant_show_comments":"1","participant_show_navigation":"","participant_show_list_button":"1","participant_show_captcha":"","big_image_width":"","big_image_height":"","med_image_width":"","med_image_height":"","small_image_width":"","small_image_height":"","crop_image_ratio":"","preview_image_width":"","gallery_thumb_width":"","gallery_thumb_height":"","gallery_thumb_method":"","import_resize_method":"","watermark":"","watermark_med":"","wm_transparency":"","wm_margin_right":"","wm_margin_bottom":"","video_thumb_width":"","video_thumb_height":""}

"participants_default_order":"title","participants_default_order_dirn":"ASC" is pretty clearly there.

I'm not sure why it's pulling "votes DESC", but it's obviously ignoring what is in the database for default ordering.

The topic has been locked.
7 months 2 weeks ago #1935
Dmitry's Avatar
Posts: 661
Something wrong with ordering and the params

Hello Theodore.

Ordering parameters are pulled out from a user state. Basically if you once change them on the contest page then they will be stored in the user state and reused.

But I do not exclude that there is a bug. If you are logged in try to log out and check one more time. Or try to use another browser.

Best regards,
Dmitry.


Like our extensions and support?
Add your voice to the JED listing with a 5-score review: bit.ly/2ciJBqC
Thanks!
The topic has been locked.
7 months 2 weeks ago #1936
Topic Author
Theodore Hildebrandt's Avatar
Posts: 6
Something wrong with ordering and the params

I was not logged in, and cleared cache to see if it was stuck in user state cache before posting.

I also have no frontend sorting available on page, so it isn't even selectable on the frontend of my competition.

The topic has been locked.
7 months 2 weeks ago #1937
Dmitry's Avatar
Posts: 661
Something wrong with ordering and the params

Ok, thank you. Will investigate.

Dmitry


Like our extensions and support?
Add your voice to the JED listing with a 5-score review: bit.ly/2ciJBqC
Thanks!
The topic has been locked.
7 months 2 weeks ago #1938
Topic Author
Theodore Hildebrandt's Avatar
Posts: 6
Something wrong with ordering and the params

Just a note here: For me, this is not so big a deal -- I just hardcoded what I wanted into the query because I know this will never change on the site. But, it would be preferable that the parameters work as expected.

The topic has been locked.
7 months 2 weeks ago #1939
Dmitry's Avatar
Posts: 661
Something wrong with ordering and the params

Of course.

About hardcode - can I ask why did you do it? Do you miss something in the query?

I am asking because there was a plan to add some more event triggers for plugins that would allow to modify the query on the fly. Is this something you are missing at the moment?


Like our extensions and support?
Add your voice to the JED listing with a 5-score review: bit.ly/2ciJBqC
Thanks!
The topic has been locked.
7 months 2 weeks ago #1940
Topic Author
Theodore Hildebrandt's Avatar
Posts: 6
Something wrong with ordering and the params

For this site, the entries need to be sorted on the frontend by title, and if they are being sorted by vote, it doesn't sort by title. I need this to happen today, so I can't really wait for a fix.

The topic has been locked.
7 months 2 weeks ago #1941
Dmitry's Avatar
Posts: 661
Something wrong with ordering and the params

I think I found the issue. The model's populateState() method is called from scratch every time when the model is called and if it is not called initially after the model object is being instantiated. As a result competition object is null.

To fix this please open controller.php and add $model->populateState(); after line 268. It should look like this:

$competition = $model->getCompetition($competitionId);
$model->populateState();

Let me know did it help or not.

Dmitry


Like our extensions and support?
Add your voice to the JED listing with a 5-score review: bit.ly/2ciJBqC
Thanks!
Last edit: 7 months 2 weeks ago by Dmitry.
The topic has been locked.
6 months 1 week ago #1996
Dmitry's Avatar
Posts: 661
Something wrong with ordering and the params

Fixed in version 1.7.8.


Like our extensions and support?
Add your voice to the JED listing with a 5-score review: bit.ly/2ciJBqC
Thanks!
The topic has been locked.

You can get our help: Monday - Friday / 09:00 to 17:00 (GMT+2). but not limited. Our staff will be pleased to provide Premium support to every paid subscriber asap, but sometimes you should be ready to wait for our reply for up to 3 days. In case of free extensions we do the best to develop and maintain them either, but their support is not necessary.

Product Latest Update