• Resolved CarolLeung

    (@carolleung)


    I designed a website for my client for a real estate enjoys using the YASR rating functions on his website for awhile, but after rating his properties for a few months, he wants to rearrange the order of the multiset elements.

    I know in the WordPress Settings > Multi Set > you can change the order from there, but the star ratings that have already been rated then no longer correspond with element that they used to.

    Is it possible to rearrange the order of the multi set elements along with the stars that were rated with them previously?

    Ex:
    Community environment 3.5
    Community external environment 4.5
    Housing Status 5
    Transportation convenience 3.5
    Life convenience 4

    He wants to change it to:
    Housing Status 5
    Transportation convenience 3.5
    Life convenience 4
    Community environment 3.5
    Community external environment 4.5

    He already rated and added many properties, he would just like to rearrange the order and don’t want to rate them all over again after the arrangement.

    https://wordpress.org/plugins/yet-another-stars-rating/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter CarolLeung

    (@carolleung)

    When I change the order of the multi sets elements in the backend, the stars don’t change with them:

    Housing Status 3.5
    Transportation convenienc 4.5
    Life convenience 5
    Community environment 3.5
    Community external environment 4

    Which is not correct…

    Plugin Contributor dudo

    (@dudo)

    Hello, tank you for using Yasr!

    Yes, this is possible, but it require to edit the code each time you update the plugin.

    IS this ok?

    Thread Starter CarolLeung

    (@carolleung)

    Yes, that is fine. I will keep note of it before each update.

    Which PHP file or code which the elements reside?

    Plugin Contributor dudo

    (@dudo)

    First, backup your database: do not do this if you can’t backup!!

    open the table _yasrmulti_set_fields with phpmyadmin, you should have a situation similiar to this

    id 	parent_set_id 	field_name 	field_id
       0 	1 	        Housing Status 	0
       1 	1 	        Transportation convenienc 	1
       2 	1 	        Life convenience 	2
       3 	1 	        Community environment 	3
       4 	1 	        Community external environment 	4

    You’ve to change the id value, e.g.

    id 	parent_set_id 	field_name 	field_id
    7 	1 	        Housing Status 	0
    8 	1 	        Transportation convenienc 	1
    9 	1 	        Life convenience 	2
    5 	1 	        Community environment 	3
    6 	1 	        Community external environment 	4

    You’ve to do this only 1 time.

    Then, open file lib/yasr-shortcodes.php and change on line 463 change this

    $set_name_content=$wpdb->get_results($wpdb->prepare("SELECT field_name AS name, field_id AS id
                            FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
                            WHERE parent_set_id=%d
                            ORDER BY field_id ASC", $setid));

    weth this

    $set_name_content=$wpdb->get_results($wpdb->prepare("SELECT field_name AS name, field_id
                            FROM " . YASR_MULTI_SET_FIELDS_TABLE . "
                            WHERE parent_set_id=%d
                            ORDER BY id ASC", $setid));
    Thread Starter CarolLeung

    (@carolleung)

    lib/yasr-shortcode-functions.php?

    Thread Starter CarolLeung

    (@carolleung)

    Is element #1 assigned to id 0?

    if so, wouldn’t it be from

    id
    0
    1
    2
    3
    4

    to:

    3
    4
    0
    1
    2?

    Thread Starter CarolLeung

    (@carolleung)

    Do I have have to have phpmyadmin?

    Could it be possible to make changes through just the backend /wp-admin under Plugins > Editor?

    Plugin Contributor dudo

    (@dudo)

    Is element #1 assigned to id 0?

    if so, wouldn’t it be from

    id
    0
    1
    2
    3
    4

    to:

    3
    4
    0
    1
    2?

    Is element #1 assigned to id 0?

    if so, wouldn’t it be from

    id
    0
    1
    2
    3
    4

    to:

    3
    4
    0
    1
    2?

    no

    Do I have have to have phpmyadmin?

    yes

    Could it be possible to make changes through just the backend /wp-admin under Plugins > Editor?

    You can edit the lib/yasr-shortcode-functions.php file here, but for acces to db you need phpmyadmin.
    If you never used this, just don’t do this change

    Thread Starter CarolLeung

    (@carolleung)

    Isn’t there an easier way to just rearrange the rows of the tables <tr>?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Rearranging order of multiset elements (along with already rated stars)’ is closed to new replies.