Superbegood31 Posted May 14, 2014 Share Posted May 14, 2014 (edited) Bonjour,Prestashop 1.6 intègre un compteur de caractères pour les balises méta dans l'onglet SEO des fiches produits.Serait-il possible d'inclure cette fonction dans toutes les pages où se trouve des balises méta ?Ne s'agirait-il pas de la fonction countDown dans le template input_text_lang.tpl ?Merci. Edited November 25, 2014 by SWITCHBOARD (see edit history) Link to comment Share on other sites More sharing options...
Superbegood31 Posted May 19, 2014 Author Share Posted May 19, 2014 up Link to comment Share on other sites More sharing options...
Superbegood31 Posted June 4, 2014 Author Share Posted June 4, 2014 up Link to comment Share on other sites More sharing options...
Superbegood31 Posted November 18, 2014 Author Share Posted November 18, 2014 re up Link to comment Share on other sites More sharing options...
Superbegood31 Posted November 25, 2014 Author Share Posted November 25, 2014 La solution pour utiliser le compteur de caractères pour vos balises méta Dans les fields_form des controllers de vos modules Pour meta_title Ajouter 'maxchar' => 70 Pour meta_decription Ajouter 'maxchar' => 160 Par exemple : AdminCmsController.php array( 'type' => 'text', 'label' => $this->l('Meta title'), 'name' => 'meta_title', 'id' => 'name', // for copyMeta2friendlyURL compatibility 'lang' => true, 'required' => true, 'class' => 'copyMeta2friendlyURL', 'hint' => $this->l('Invalid characters:').' <>;=#{}', 'maxchar' => 70 array( 'type' => 'text', 'label' => $this->l('Meta description'), 'name' => 'meta_description', 'lang' => true, 'hint' => $this->l('Invalid characters:').' <>;=#{}', 'maxchar' => 160 C'est tout Link to comment Share on other sites More sharing options...
Superbegood31 Posted November 25, 2014 Author Share Posted November 25, 2014 Une autre petite idée : Ajouter une class CSS pour mettre en évidence lorsque l'on dépasse le max-char Mais mon code ne fonctionne pas Dans themes\default\template\helpers\form\form.tpl function addClasse() { var seochar = $('#meta_title_4_counter').val().length; if (seochar < 0) { $('#meta_title_4_counter').addClass('seo-nok'); } } et j'ai ajouté addClasse(); au keyup Si quelqu'un a une idée... Link to comment Share on other sites More sharing options...
Superbegood31 Posted November 26, 2014 Author Share Posted November 26, 2014 (edited) J'avance mais le fonctionnement n'est pas optimal function addClasse() { var maxchartitle = $('#meta_title_' + id_language + '_counter').text(); var maxchardescription = $('#meta_description_' + id_language + '_counter').text(); if (maxchartitle <= "0") { $('#meta_title_' + id_language + '_counter').addClass('seo-nok'); } else if (maxchardescription <= "0") { $('#meta_description_' + id_language + '_counter').addClass('seo-nok'); } else { $('#meta_title_' + id_language + '_counter').removeClass('seo-nok'); $('#meta_description_' + id_language + '_counter').removeClass('seo-nok'); } } Si on dépasse le maxchar, le css s'applique immédiatement. Mais si on revient en arrière et que le maxchar est inférieur ou égal alors le css ne revient pas normalement... Cas concret : On rentre du texte et on arrive à -1 la classe seo-nok s'ajoute On supprime du texte et on arrive à 0 la classe seo-nok ne s'enlève pas (elle s'enlève à 2) Edited November 26, 2014 by SWITCHBOARD (see edit history) 1 Link to comment Share on other sites More sharing options...
Nanou2301 Posted December 10, 2014 Share Posted December 10, 2014 La solution pour utiliser le compteur de caractères pour vos balises méta Dans les fields_form des controllers de vos modules Pour meta_title Ajouter 'maxchar' => 70 Pour meta_decription Ajouter 'maxchar' => 160 Par exemple : AdminCmsController.php array( 'type' => 'text', 'label' => $this->l('Meta title'), 'name' => 'meta_title', 'id' => 'name', // for copyMeta2friendlyURL compatibility 'lang' => true, 'required' => true, 'class' => 'copyMeta2friendlyURL', 'hint' => $this->l('Invalid characters:').' <>;=#{}', 'maxchar' => 70 array( 'type' => 'text', 'label' => $this->l('Meta description'), 'name' => 'meta_description', 'lang' => true, 'hint' => $this->l('Invalid characters:').' <>;=#{}', 'maxchar' => 160 C'est tout Merci !!! J'ai cherché cette fonction pendant des heures, et n'aurai jamais pensé que la solution serait aussi simple ! Encore merci d'avoir partagé ta solution ! Link to comment Share on other sites More sharing options...
Superbegood31 Posted December 10, 2014 Author Share Posted December 10, 2014 Avec plaisir, ravi d'avoir rendu service Link to comment Share on other sites More sharing options...
Jean.M Posted December 11, 2014 Share Posted December 11, 2014 Merci beaucoup pour cette solution qui va me faire gagner un temps fou de copier/coller depuis notepad++ Par contre, ou dois-je mettre le code? Merci Link to comment Share on other sites More sharing options...
Superbegood31 Posted December 11, 2014 Author Share Posted December 11, 2014 Bonjour, Par exemple : AdminCmsController.php Dans le fields_form (ligne 110) Ajouter la varaible max-char Meta_title array( 'type' => 'text', 'label' => $this->l('Meta title'), 'name' => 'meta_title', 'id' => 'name', // for copyMeta2friendlyURL compatibility 'lang' => true, 'required' => true, 'class' => 'copyMeta2friendlyURL', 'hint' => $this->l('Invalid characters:').' <>;=#{}', 'maxchar' => 70 Meta_description array( 'type' => 'text', 'label' => $this->l('Meta description'), 'name' => 'meta_description', 'lang' => true, 'hint' => $this->l('Invalid characters:').' <>;=#{}', 'maxchar' => 160 1 Link to comment Share on other sites More sharing options...
Jean.M Posted December 11, 2014 Share Posted December 11, 2014 Merci Link to comment Share on other sites More sharing options...
Superbegood31 Posted December 12, 2014 Author Share Posted December 12, 2014 Avec plaisir 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