grupaperun Posted May 8, 2019 Share Posted May 8, 2019 Hello, how can I change contact form subjects order? Now it's sorted alphabetically by subject names. I would like to sort subjects by ID in ascending order. I use Prestashop 1.7.5.1. Here is the code from contactform.tpl <div class="form-group row"> <label class="col-md-3 form-control-label">{l s='Subject' d='Shop.Forms.Labels'}</label> <div class="col-md-9 col-lg-6"> <select name="id_contact" class="form-control form-control-select"> {foreach from=$contact.contacts item=contact_elt} <option value="{$contact_elt.id_contact}">{$contact_elt.name}</option> {/foreach} </select> </div> </div> Please help. Link to comment Share on other sites More sharing options...
Rolige Posted May 9, 2019 Share Posted May 9, 2019 Hello: You should order the list before pass it to the tpl, in the corresponding PHP file. Regards Link to comment Share on other sites More sharing options...
sandra nanou Posted August 13, 2019 Share Posted August 13, 2019 Hi, Have you found a solution? Thank you Link to comment Share on other sites More sharing options...
VeeTee Posted January 22, 2020 Share Posted January 22, 2020 Hi, So all I did was, I put a number in front of the department (1. Information, 2. Support, 3. Webmaster) so that it's going according to this order, which is what the client wanted. Not ideal but the easiest way to do it. Link to comment Share on other sites More sharing options...
sandra nanou Posted January 22, 2020 Share Posted January 22, 2020 Hi, It's also what I ended it up doing! I couldn't find any other way. Thanks for your answer 1 Link to comment Share on other sites More sharing options...
Marcellog19 Posted September 15, 2020 Share Posted September 15, 2020 (edited) You can override class Contact.php Copy /classes/Contact.php in /override/classes and write /** * Class Contact */ class Contact extends ContactCore { /** * Return available contacts * @param int $idLang Language ID * @return array Contacts */ public static function getContacts($idLang) { $shopIds = Shop::getContextListShopID(); $sql = 'SELECT * FROM `'._DB_PREFIX_.'contact` c '.Shop::addSqlAssociation('contact', 'c', false).' LEFT JOIN `'._DB_PREFIX_.'contact_lang` cl ON (c.`id_contact` = cl.`id_contact`) WHERE cl.`id_lang` = '.(int) $idLang.' AND contact_shop.`id_shop` IN ('.implode(', ', array_map('intval', $shopIds)).') GROUP BY c.`id_contact` ORDER BY `name` ASC'; return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); } } By default, order is by name. I replace by position and in Database > "ps_contact" table I change value for position column. PS : clear cache (remove all cache in /var/cache) Edited September 15, 2020 by Marcellog19 (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now