Jump to content

1.7 - Ordre sujet formulaire de contact


Recommended Posts

Bonjour,

Je cherche à modifier l'ordre des sujets dans la liste déroulante du formulaire de contact, une idée de comment procéder ?

J'ai tenté un sortby dans le foreach de contactform.tpl  mais j'ai une message d'erreur :

 {foreach from=$contact.contacts|@sortby:id  item=contact_elt}

Merci pour votre aide :)

Edited by sandra nanou (see edit history)
Link to comment
Share on other sites

Merci pour votre message !

Je suis sur un prestashop 1.7.5.2 et le message d'erreur est le suivant :

"Syntax error in template "file:/var/www/prestashop/themes/montheme/modules/contactform/views/templates/widget/contactform.tpl" on line 70 "

{foreach from=$contact.contacts|@sortby:id item=contact_elt}" unknown modifier 'sortby'"

Link to comment
Share on other sites

Bonjour,  pourquoi ne pas overrider les fonctions de Contact.php avec un ORDER BY

   /**
     * 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);
    }

    /**
     * Return available categories contacts.
     *
     * @return array Contacts
     */
    public static function getCategoriesContacts()
    {
        $shopIds = Shop::getContextListShopID();

        return Db::getInstance()->executeS('
            SELECT cl.*
            FROM ' . _DB_PREFIX_ . 'contact ct
            ' . Shop::addSqlAssociation('contact', 'ct', false) . '
            LEFT JOIN ' . _DB_PREFIX_ . 'contact_lang cl
                ON (cl.id_contact = ct.id_contact AND cl.id_lang = ' . (int) Context::getContext()->language->id . ')
            WHERE ct.customer_service = 1
            AND contact_shop.`id_shop` IN (' . implode(', ', array_map('intval', $shopIds)) . ')
            GROUP BY ct.`id_contact`
        ');

 

cordialement

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...