Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author alordiel

    (@alordiel)

    Hi,

    Can you tell me which option are you using. Are you adding the option manually or you are using the multisite option?

    Regards,
    Al

    Thread Starter NewPixels

    (@newpixels)

    Hi,
    I am adding the options manually.
    Max

    Plugin Author alordiel

    (@alordiel)

    I have tried different methods for changing the code but none of them worked. I will try something else later and will let you know of the results.

    Thread Starter NewPixels

    (@newpixels)

    Ok thank you! I hope you find something as it would be a great feature!

    Plugin Author alordiel

    (@alordiel)

    Ok, so the things are not straight forward you will need to touch a bit of code. Hope you have FTP access cuz I need you to open the file named : dropdown-multisite-selector.php. It should be located in : wp-content/plugins/dropdown-multisite-selector.

    Once you have opened the php file find function called function noneOptions(). It it you will find a some rows like:

    if ( $options ) {
      foreach ( $options as $key => $value ) {
    	$out .= "<option value='" . $value . "'>" . $key . "</option>";
      }
    }

    Then you need to add this one line of code between the if and the foreach :
    $options = array_reverse($options);

    So your new code should look like:

    if ( $options ) {
      $options = array_reverse($options);
      foreach ( $options as $key => $value ) {
    	$out .= "<option value='" . $value . "'>" . $key . "</option>";
      }
    }

    Then save the file and upload it back to your ftp from where you have opened it.

    Then everything should work.
    Sorry for the ‘hard way’ of doing something that seems to be out of the box but hope that some day will have time to finish the next version and will include this in it for sure.

    Regards,
    Al

    Thread Starter NewPixels

    (@newpixels)

    Thank You so much! All sorted and working nicely!

    Hi Al, I tried the suggested change you posted and it worked but I was getting the array index values in my dropdown list box (e.g. 0, 1, 2…) instead of the values. So I did a little research on the php function array_reverse and, in one of the forums I found, it was suggested that you add the following parameter to the function “preserve_keys”.

    So I made one slight modification to your code line as follows:
    $options = array_reverse($options, TRUE);

    Adding the parameter with the value of TRUE explicitly fixed the above mentioned problem. Now it works perfectly with my list values showing the actual values in reverse order.

    Thank you for your help

    • This reply was modified 8 years, 2 months ago by sasqwatch.
    Plugin Author alordiel

    (@alordiel)

    Hi, Thank you a lot for your comment. Really helpfull and I will have in mind this tip when implementing this feature.
    Regards,
    Al

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Changing the Dropdown fields Order’ is closed to new replies.