limiter tep_get_category_tree[Résolu] |
Bienvenue invité ( Connexion | Inscription )
limiter tep_get_category_tree[Résolu] |
8 Sep 2015, 10:18
Message
#1
|
|
Ceinture jaune+ OSC Groupe : Membres Messages : 124 Inscrit : 7-November 07 Lieu : Lyon Membre no 19668 |
Salut,
Je cherche à limiter l'affichage du menu déroulant de la page categories.php lors du déplacement d'une catégorie. En clair, dans l'arborescence suivante, si j'ai besoin de déplacer soussouscat1, je ne dois pouvoir le faire que dans les souscat et les soussouscat de cat2 : -cat1 -souscat1 -souscat2 -cat2 -souscat3 -soussouscat1 -soussouscat2 -souscat4 -cat3 Basiquement, j'ai modifié categories.php : Code $contents[] = array('text' => '<br />' . sprintf(TEXT_MOVE, $cInfo->categories_name) . '<br />' . tep_draw_pull_down_menu('move_to_category_id', tep_get_category_tree(), $current_category_id)); par Code $contents[] = array('text' => '<br />' . sprintf(TEXT_MOVE, $cInfo->categories_name) . '<br />' . tep_draw_pull_down_menu('move_to_category_id', tep_get_category_tree_catalog(), $current_category_id)); puis dans general.php j'ai dupliqué tep_get_category_tree et modifié en tep_get_category_tree_catalog : Code function tep_get_category_tree_catalog($parent_id = '0', $spacing = '', $exclude = '', $category_tree_array = '', $include_itself = false) { global $languages_id; if (!is_array($category_tree_array)) $category_tree_array = array(); if ( (sizeof($category_tree_array) < 1) && ($exclude != '0') ) $category_tree_array[] = array('id' => '0', 'text' => TEXT_TOP); if ($include_itself) { $category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.language_id = '" . (int)$languages_id . "' and cd.categories_id = '" . (int)$parent_id . "'"); $category = tep_db_fetch_array($category_query); $category_tree_array[] = array('id' => $parent_id, 'text' => $category['categories_name']); } $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and c.parent_id = '" . (int)$parent_id . "' order by c.sort_order, cd.categories_name"); while ($categories = tep_db_fetch_array($categories_query)) { if ($exclude != $categories['categories_id']) $category_tree_array[] = array('id' => $categories['categories_id'], 'text' => $spacing . $categories['categories_name']); $category_tree_array = tep_get_category_tree($categories['categories_id'], $spacing . ' ', $exclude, $category_tree_array); } return $category_tree_array; } Mais à partir de là, je me gratte la tête sur les modifications à apporter. Y aurait-il un moyen "simple' d'obtenir cette limitation ? Merci !!! Ce message a été modifié par equisol - 9 Sep 2015, 18:02. -------------------- Goo69
|
|
9 Sep 2015, 18:02
Message
#2
|
|
Ceinture jaune+ OSC Groupe : Membres Messages : 124 Inscrit : 7-November 07 Lieu : Lyon Membre no 19668 |
le moyen simple d'y arriver .... est dans la fonction même. Il suffit de modifier la valeur de $parent_id.
Code function tep_get_category_tree_catalog($parent_id = '3', $spacing = '', $exclude = '', $category_tree_array = '', $include_itself = true) { global $languages_id; if (!is_array($category_tree_array)) $category_tree_array = array(); // if ( (sizeof($category_tree_array) < 1) && ($exclude != '0') ) $category_tree_array[] = array('id' => '0', 'text' => TEXT_TOP); if ($include_itself) { $category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.language_id = '" . (int)$languages_id . "' and cd.categories_id = '" . (int)$parent_id . "'"); $category = tep_db_fetch_array($category_query); $category_tree_array[] = array('id' => $parent_id, 'text' => '<>' . $category['categories_name'] . '<>'); } $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and c.parent_id = '" . (int)$parent_id . "' order by c.sort_order, cd.categories_name"); while ($categories = tep_db_fetch_array($categories_query)) { if ($exclude != $categories['categories_id']) $category_tree_array[] = array('id' => $categories['categories_id'], 'text' => $spacing . $categories['categories_name']); $category_tree_array = tep_get_category_tree($categories['categories_id'], $spacing . ' ', $exclude, $category_tree_array); } return $category_tree_array; } J'ai aussi mis de côté la ligne suivante histoire que l'on ne puisse pas déplacer le dossier à la racine de l'arborescence : Code if ( (sizeof($category_tree_array) < 1) && ($exclude != '0') ) $category_tree_array[] = array('id' => '0', 'text' => TEXT_TOP);
-------------------- Goo69
|
|
Version bas débit | Nous sommes le : 28th March 2024 - 23:47 |
Ce site est déclaré auprès de la commision Nationale de l'Informatique et des Libertés (déclaration n°: 1043896) |