1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

force alphabetical listing of custom fields

Discussion in 'XenForo Questions and Support' started by Live Free, Jul 25, 2012.

  1. Live Free

    Live Free Active Member

    I have over 100 custom field options that are not listed alphabetically. I'd like to list them alphabetically, from a-z, so users can select the proper field more easily (without thinking it's not an option). When I entered them I assumed it'd be alphabetical but it's not.

    Is there anything I can do aside from re-entering them manually, which would be time-consuming? Perhaps a database query?

    Thanks in advance.
     
  2. Russ

    Russ Well-Known Member

    Live Free likes this.
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    You can run these queries to set all display orders on custom fields according to the alphabetical orders of the field_ids:

    Code:
    CREATE TABLE xf_user_field_order (
    	`order` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    	field_id VARCHAR(25) NOT NULL
    );
    
    INSERT INTO xf_user_field_order (field_id)
    	SELECT uf.field_id
    	FROM xf_user_field AS uf
    	ORDER BY uf.field_id
    	ASC;
    
    UPDATE xf_user_field AS uf, xf_user_field_order AS ufo
    SET uf.display_order = ufo.order
    WHERE uf.field_id = ufo.field_id;
    
    DROP TABLE xf_user_field_order;
    
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Oh wait... are we talking about multiple custom fields? Or just one custom field with multiple options? These queries are for ordering multiple custom fields amongst themselves.
     
  5. Live Free

    Live Free Active Member

    My issue is with one custom field that has many options.
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Yeah that requires an addon.
     

Share This Page