Bienvenue invité ( Connexion | Inscription )
11 Sep 2008, 21:56
Message
#1
|
|
![]() Ceinture marron OSC Groupe : Membres Messages : 1690 Inscrit : 10-October 06 Lieu : Rives du Lez Membre no 12571 |
hello,
bon comme j'ai pas la science infuse, je pose la question. Je travaille sur la boxe catégories (pas des plus simples à modifier) et souhaite afficher l'image de la catégorie active dedans. donc je suis parti du code original de la boxe categories et j'ai ajouté après : Code tep_show_category($first_element); $info_box_contents = array(); $info_box_contents[] = array('text' => $categories_string); ceci : Code if ($cPath>0){ $info_box_contents[] = array('text' => tep_image(DIR_WS_IMAGES . tep_get_category_image($categories_image), tep_get_category_image($categories_name), 128, 128)); } évidemment, la fonction tep_get_category_image n'existe pas, donc je l'ai créé dans le fichier general.php : Code //// // Return a category image function tep_get_category_image($language = '') { global $languages_id; global $current_category_id; if (empty($language)) $language = $languages_id; $category_image_query = tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . $current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'"); $category_image = tep_db_fetch_array($category_image_query); return $category_image['categories_image']; } //// la question que je me pose, c'est est ce que j'ai pas réinventé la roue ? n'y a t'il pas une autre solution en exploitant déjà le code existant de la boxe, voir des fonctions natives d'oscommerce ? j'ai pas mal trituré mes poves méninges, mais à mon niveau, j'ai vu que ça... Qu'en pensez vous ? 'ci les zamis ! cdt -------------------- "Pourquoi vois-tu la paille qui est dans l'oeil de ton frère et n'aperçois-tu pas la poutre qui est dans ton oeil ?".(Saint Luc, VI-41)
|
|
|
![]() |
12 Sep 2008, 15:06
Message
#2
|
|
![]() Ceinture marron OSC Groupe : Membres Messages : 1690 Inscrit : 10-October 06 Lieu : Rives du Lez Membre no 12571 |
non, j'ai pas besoin de l'exploder, le $cPath est toujours un entier avec mon code.
regarde je te mets le code de la boxe categories que j'exploite actuellement : Code <?php /* $Id: categories.php 1739 2007-12-20 00:52:16Z hpdl $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ function tep_show_category($counter) { global $tree, $categories_string, $cPath_array, $current_category_id; for ($i=0; $i<$tree[$counter]['level']; $i++) { $categories_string .= " "; } $categories_string .= '<a href="'; if ($tree[$counter]['parent'] == 0) { $cPath_new = 'cPath=' . $counter; } else { $cPath_new = 'cPath=' . $tree[$counter]['path']; } $categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">'; if (isset($cPath_array) && in_array($counter, $cPath_array)) { $categories_string .= '<b>'; } // display category name $categories_string .= $tree[$counter]['name']; if (isset($cPath_array) && in_array($counter, $cPath_array)) { $categories_string .= '</b>'; } if (tep_has_category_subcategories($counter)) { $categories_string .= ''; } $categories_string .= '</a>'; if (SHOW_COUNTS == 'true') { $products_in_category = tep_count_products_in_category($counter); if ($products_in_category > 0) { $categories_string .= ' (' . $products_in_category . ')'; } } $categories_string .= '<br>'; if ($tree[$counter]['next_id'] != false) { tep_show_category($tree[$counter]['next_id']); } } ?> <!-- categories //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_CATEGORIES); new infoBoxHeading($info_box_contents, true, true); $categories_string = ''; $tree = array(); //$categories_query = tep_db_query("select c.categories_id, c.categories_image, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, c.parent_id, cd.categories_name"); $categories_query = tep_db_query("select c.categories_id, c.categories_image, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$cPath . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name"); while ($categories = tep_db_fetch_array($categories_query)) { $tree[$categories['categories_id']] = array('name' => $categories['categories_name'], 'image' => $categories['categories_image'], 'parent' => $categories['parent_id'], 'level' => 0, 'path' => $categories['categories_id'], 'next_id' => false); if (isset($parent_id)) { $tree[$parent_id]['next_id'] = $categories['categories_id']; } $parent_id = $categories['categories_id']; if (!isset($first_element)) { $first_element = $categories['categories_id']; } } //------------------------ if (tep_not_null($cPath)) { $new_path = ''; reset($cPath_array); while (list($key, $value) = each($cPath_array)) { unset($parent_id); unset($first_id); $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$value . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name"); if (tep_db_num_rows($categories_query)) { $new_path .= $value; while ($row = tep_db_fetch_array($categories_query)) { $tree[$row['categories_id']] = array('name' => $row['categories_name'], 'image' => $row['categories_image'], 'parent' => $row['parent_id'], 'level' => $key+1, 'path' => $new_path . '_' . $row['categories_id'], 'next_id' => false); if (isset($parent_id)) { $tree[$parent_id]['next_id'] = $row['categories_id']; } $parent_id = $row['categories_id']; if (!isset($first_id)) { $first_id = $row['categories_id']; } $last_id = $row['categories_id']; } $tree[$last_id]['next_id'] = $tree[$value]['next_id']; $tree[$value]['next_id'] = $first_id; $new_path .= '_'; } else { break; } } } tep_show_category($first_element); $info_box_contents = array(); $info_box_contents[] = array('text' => $categories_string); if ($cPath > 0) { // le $cPath est toujours un entier et correspond à la current_category_id echo $cPath; // fin du com pour gentag;o) $info_box_contents[] = array('text' => tep_image(DIR_WS_IMAGES . tep_get_category_image($categories_image), tep_get_category_image($categories_name), 128, 128)); }else{ $info_box_contents[] = array('text' => tep_image(DIR_WS_IMAGES. $tree[$current_category_id]['image'], $tree[$current_category_id]['name'], 128, 128)); } new infoBox($info_box_contents); ?> </td> </tr> <!-- categories_eof //--> d'ailleurs, en mettant dans le fichier general.php (code corrigé sur les conseil de shoprun) : Code function tep_get_category_image($categories_id) { global $languages_id; global $current_category_id; if (empty($language)) $language = $languages_id; $category_image_query = tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . $current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'"); $category_image = tep_db_fetch_array($category_image_query); return $category_image['categories_image']; } et que tu mets à la place de : Code $info_box_contents[] = array('text' => tep_image(DIR_WS_IMAGES . tep_get_category_image($categories_image), tep_get_category_image($categories_name), 128, 128)); ça : Code $info_box_contents[] = array('text' => tep_image(DIR_WS_IMAGES . tep_get_category_image($cPath), tep_get_category_image($categories_name), 128, 128)); tu obtiens le même résultat. question à 1000 croquettes au poisson : comment exploiter avec le tableau $tree cette valeur $cPath comme une $categories_id pour appeler l'image qui lui correspond ? (pas d'égalité sur $cpath , ça fait foirer le script) Ce message a été modifié par coconimo - 12 Sep 2008, 15:27. -------------------- "Pourquoi vois-tu la paille qui est dans l'oeil de ton frère et n'aperçois-tu pas la poutre qui est dans ton oeil ?".(Saint Luc, VI-41)
|
|
|
coconimo Img des catégories mères&filles dans la boxe catégories 11 Sep 2008, 21:56
shoprun Salut
Une petite erreur ici je pense : tep_get_ca... 12 Sep 2008, 05:45
coconimo Citation (shoprun @ 12 Sep 2008, 07:45) S... 12 Sep 2008, 07:38
shoprun Citation (coconimo @ 12 Sep 2008, 10:38) ... 12 Sep 2008, 08:07
coconimo youpi, ayé, j'ai trouvé, ct plus simple qu... 12 Sep 2008, 08:21
shoprun Ben voilà, et puis hop, une petite requête d'é... 12 Sep 2008, 08:27
coconimo tiens, voilà le code de la boxe categories origina... 12 Sep 2008, 13:08
coconimo crotte de bique, j'ai floodé en postant ! 12 Sep 2008, 13:10
gentag Bonjour,
J'ai pas trop eu le temps ce matin, ... 12 Sep 2008, 14:10
coconimo enfait gentag, ça marche et ça marche pas ...
si j... 12 Sep 2008, 14:38
gentag Re,
Bah le cPath tu l'explode par le caractèr... 12 Sep 2008, 15:01
gentag Re,
Bah je pense un peu comme shoprun, le fait d... 12 Sep 2008, 15:57
shoprun Il y a un souci dans la fonction, car celle ci fai... 12 Sep 2008, 16:16
coconimo après la première boucle while ($categories =... 12 Sep 2008, 19:10
shoprun Bon, j'ai installé une MS2-FR-W3C-3, et j... 13 Sep 2008, 10:06
coconimo slt shoprun,
je vais regarder ton code de très prè... 13 Sep 2008, 11:18
coconimo @ shoprun:
bon, je viens de tester ton code, sur u... 13 Sep 2008, 20:20
shoprun Exact Coconimo, ce n'était pas le top, loin de... 13 Sep 2008, 21:08
coconimo oui, j'ai bien l'impression qu'on arri... 13 Sep 2008, 21:40
delete Je passe par là je n'ai pas tout suivi mais je... 14 Sep 2008, 09:15
coconimo Citation (delete @ 14 Sep 2008, 11:15) .... 14 Sep 2008, 12:44
delete Meskine le chat pleurniche !
En bref tu ve... 14 Sep 2008, 16:21
coconimo c presque ça mon 'tit Delete.
sauf pour : Et t... 14 Sep 2008, 16:51
delete Citation (coconimo @ 14 Sep 2008, 17:51) ... 14 Sep 2008, 17:04
gentag Bonjour,
Bon bah aujourd'hui ça être tendu...... 15 Sep 2008, 09:19
delete Citation (gentag @ 15 Sep 2008, 10:19) Ma... 15 Sep 2008, 09:25
coconimo oki les garçons.
voici le scénario :
on a dans le ... 15 Sep 2008, 10:05
gentag Re,
J'étais en train de me dire... pourquoi a... 15 Sep 2008, 12:04
coconimo alors ne mélangeons pas tout.
le code pour padaben... 15 Sep 2008, 14:00
gentag Re,
Bah je ne mélangeais pas... au contraire, je ... 15 Sep 2008, 14:17
delete Citation (coconimo @ 15 Sep 2008, 15:00) ... 15 Sep 2008, 14:33
gentag Plus de chat... ?
Tant pis, je finis comme ça et ... 15 Sep 2008, 15:01
gentag Bon bein ça fonctionne parfaitement... les dernièr... 15 Sep 2008, 17:01
coconimo alors, mon 'tit gentag, je reste dubitative ..... 15 Sep 2008, 17:52
shoprun Citation (coconimo @ 15 Sep 2008, 20:52) ... 15 Sep 2008, 19:47
delete Citation (coconimo @ 15 Sep 2008, 18:52) ... 15 Sep 2008, 20:20
coconimo oula, je ne veux chatouiller personne.
je vais syn... 15 Sep 2008, 21:15
gentag Re,
sinon je pense toujours comme shoprun que c... 15 Sep 2008, 22:20
shoprun Citation je vais synthétiser les diverses réponses... 16 Sep 2008, 06:06
gentag Salut shoprun,
en fait, je (pen)sais (savoir... ... 16 Sep 2008, 06:35
shoprun @Gentag
Je viens de constater ceci dans le titre -... 16 Sep 2008, 07:22
coconimo Citation (coconimo @ 15 Sep 2008, 12:05) ... 16 Sep 2008, 08:00
shoprun Citation l'arbre continu de se déployer si j... 16 Sep 2008, 10:44
coconimo bon, toutes mes categories n'ont pas forcément... 16 Sep 2008, 12:03
shoprun Citation (coconimo @ 16 Sep 2008, 15:03) ... 16 Sep 2008, 15:50
coconimo bon, quoi qu'il en soit, faudra que je revois ... 16 Sep 2008, 21:57
gentag Bonsoir,
euh... tu as eu ça sur mon code ?
Citati... 16 Sep 2008, 22:23
shoprun Bon, et bien j'en conviens qu'il est préfé... 17 Sep 2008, 06:33
gentag Bonjour,
Citation Scouzy GentagBah ecoute aucun p... 17 Sep 2008, 06:48
gentag Par contre, perso, je reste sur l'idée que le ... 17 Sep 2008, 07:01
shoprun Citation (gentag @ 17 Sep 2008, 09:48) Si... 17 Sep 2008, 07:09
gentag En fait, le truc que j'avais fait n'affich... 17 Sep 2008, 08:20
coconimo heu, pour l'erreur Undefined offset: 10, c... 17 Sep 2008, 08:55
shoprun Citation (gentag @ 17 Sep 2008, 11:20) c... 17 Sep 2008, 08:58
gentag Euh là je dirais qu'il n'y a presque plus ... 17 Sep 2008, 09:10
shoprun Citation (gentag @ 17 Sep 2008, 12:10) Eu... 17 Sep 2008, 09:19
coconimo bah non c pas bon si on supprime le code de gentag... 17 Sep 2008, 09:33
shoprun Citation (coconimo @ 17 Sep 2008, 12:33) ... 17 Sep 2008, 09:39
coconimo Citation (shoprun @ 17 Sep 2008, 10:58) C... 17 Sep 2008, 09:48
coconimo oki shoprun, donc j'exploite la requète du bre... 17 Sep 2008, 09:52
gentag Juste si je peux me permettre tep_not_null() est u... 17 Sep 2008, 09:57
shoprun Citation (coconimo @ 17 Sep 2008, 12:52) ... 17 Sep 2008, 10:26
coconimo oki, la jointure est faite :
j'ai donc mis dan... 17 Sep 2008, 10:27
gentag Re,
Bah ton attention me touche coconimo, vrai, m... 17 Sep 2008, 11:46
coconimo sauf que strlen() ne s'applique pas dans ce ca... 17 Sep 2008, 12:26
shoprun @Coconimo
Je viens d'essayer ton code, ça me p... 17 Sep 2008, 13:04
gentag Eh ! Mais euh !
Je sais bien que je suis u... 17 Sep 2008, 13:35
coconimo pouuuuuuuuuuuuuce !!!
pas la peine d... 17 Sep 2008, 13:45
shoprun Citation c'est que plus on fait court, plus on... 17 Sep 2008, 13:51
delete Citation (gentag @ 17 Sep 2008, 14:35) (j... 17 Sep 2008, 13:52
coconimo pour une categorie mère sans image, il suffit de r... 17 Sep 2008, 14:06
coconimo alors la solution suivante est :
pour un affichage... 17 Sep 2008, 15:14
shoprun Citation (coconimo @ 17 Sep 2008, 18:14) ... 17 Sep 2008, 15:42
coconimo alors, le mot de la fin de la fin cette fois ci:
S... 5 Oct 2008, 20:20
padaben salut à tous
ET bien je dois dire bravo ...
j... 13 Oct 2008, 13:22
padaben re salut !
j'hésite à faire un autre post... 13 Oct 2008, 14:33
gentag Bonjour,
Mouais, perso je n'ai pas (encore) i... 13 Oct 2008, 16:56
padaben Citation (gentag @ 13 Oct 2008, 18:56) Fa... 13 Oct 2008, 17:11
gentag Bonjour,
Citation Pourquoi Delete ne serait pas c... 14 Oct 2008, 14:39
padaben Bah tout va pour le mieux alors
Merci à Delete :... 14 Oct 2008, 17:53![]() ![]() |
|
Version bas débit | Nous sommes le : 21st May 2013 - 18:03 |
| Ce site est déclaré auprès de la commision Nationale de l'Informatique et des Libertés (déclaration n°: 1043896) |