Outils pour utilisateurs

Outils du site


webdev:prestashop:changer_bo

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
webdev:prestashop:changer_bo [18/05/2017 15:09] – créée dolowebdev:prestashop:changer_bo [14/08/2017 15:31] (Version actuelle) – [Ajouter un menu] dolo
Ligne 1: Ligne 1:
 +====== Modifier le back-office ======
  
 +===== Changer des listes affichées en back-office =====
 +Goto AdminMachinController -> Chercher <html><strong>$this->fields_list</strong></html>
 +
 +http://doc.prestashop.com/display/PS16/Adding+a+configuration+page
 +
 +==== Exemple avec callback ====
 +<Code>
 + 'is_pro' => array(
 + 'title' => $this->l('Pro - valid'),
 + 'align' => 'text-center',
 + 'type' => 'bool',
 + 'orderby' => false,
 + 'callback' => 'isProValid',
 + ),
 +</Code>
 +
 +Fonction dans le même fichier :
 +<Code>
 + // Fonction pour afficher si le client est pro, et s'il est ou non dans le groupe des pros non validés
 + public function isProValid($value, $customer)
 + {
 + if ($value)
 + {
 + $return = '<i class="icon-check list-action-enable action-enabled"></i> - ';
 + } else {
 + return '<i class="icon-remove list-action-enable action-disabled"></i> - <i class="icon-remove list-action-enable action-disabled"></i>';
 + }
 +
 + $groups = Customer::getGroupsStatic($customer['id_customer']);
 + $valid = true;
 + for( $i = 0, $max = count($groups) ; $i < $max ; $i++ )
 + {
 + if ( $groups[$i] == 4 )
 + {
 + $return .= '<i class="icon-remove list-action-enable action-disabled"></i>';
 + $valid = false;
 + }
 + }
 + if($valid)
 + {
 + $return .= '<i class="icon-check list-action-enable action-enabled"></i>';
 + }
 + return $return;
 + }
 +</Code>
 +
 +===== Changer les vues affichées en back-office =====
 +Pour ça il faut modifier les templates du thème admin. Ils se trouvent dans **/admin/themes/nom_du_theme/template/controllers/nom_du_controlleur/helpers/view/view.tpl**
 +
 +===== Ajouter un menu =====
 +Pour un module (need a controller).
 +
 +À l'installation :
 +<code linenums>
 + public function install()
 + {
 + // ...
 +
 + // On met le menu dans Administration
 + $presta_pop_tab = new Tab();
 + $presta_pop_tab->class_name = 'AdminPrestaPop';
 + $presta_pop_tab->module = 'presta_pop';
 +
 + $presta_pop_tab_admin_id = Tab::getIdFromClassName('AdminAdmin');
 + if ($presta_pop_tab_admin_id)
 + {
 + $presta_pop_tab->id_parent = $presta_pop_tab_admin_id;
 + } else {
 + $presta_pop_tab->id_parent = 0;
 + }
 +
 + foreach (Language::getLanguages(true) as $lang)
 + {
 + $presta_pop_tab->name[$lang['id_lang']] = 'Presta pop';
 + }
 + $presta_pop_tab->save();
 +
 + // ...
 + }
 +</code>
 +
 +Désinstallation :
 +<code linenums>
 + public function uninstall()
 + {
 + // ...
 +
 + // Virer le lien dans le menu
 + $presta_pop_tab_id = Tab::getIdFromClassName('AdminPrestaPop');
 + if ($presta_pop_tab_id)
 + {
 + $presta_pop_tab = new Tab($presta_pop_tab_id);
 + $presta_pop_tab->delete();
 + }
 +
 + // ...
 + }
 +</code>
 +
 +=== Lui donner une icône ===
 +<code linenums>
 + function install()
 + {
 + if (parent::install() == false || $this->registerHook('displayBackOfficeHeader') == false)
 + {
 + return false;
 + }
 +
 + // ...
 + }
 +
 +
 + public function hookDisplayBackOfficeHeader($params)
 + {
 + return '<style type="text/css">.icon-AdminKoregrafOptions:before{ content: "";  }</style>"';
 + }
 +</code>