Aide - Recherche - Membres - Calendrier
Version complète : (RESOLU) Supprimer les sous categories à gauche
Forum osCommerce-fr > Adapter OsCommerce MS2 > Design
TheGame
Bonjour,

Je souhaite supprimer les sous categories de GAUCHE.

Pour uniquement laissé les catégories Principal:

- HOMME
- FEMME
- CHAUSSURES
- ACCESSOIRES
- DESTOCKAGE

Je retrouveré donc les sous categories uniquement sur la droite

J' utilise une ms2.2 avec une template ( www.myfashioncrew.com )

merci de votre aide.
Celluloid
Sur une MS2-2 sans template, cela se passe dans includes/boxes/categories.php

Vers la ligne 73
Bloc A
CODE

  $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.parent_id = '0' 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))  {
    [...]

    if (!isset($first_element)) {
      $first_element = $categories['categories_id'];
    }
  }

=> Liste et stocke dans une structure les catégories dont la catégorie "parente" est la catégorie "0" === Liste les catégories de haut niveau (ici, HOMME, FEMME, CHAUSSURES, ACCESSOIRES et DESTOCKAGE)

PUIS
Oscommerce boucle sur la structure et pour chaque catégorie de "haut niveau", va chercher les sous-catégories à afficher, en fonction de la sous-catégorie où on se trouve.
C'est le gros bloc suivant qui le fait :
Bloc B (vers la ligne 92)
CODE

  //------------------------
  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.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");
      [...]
      } else {
        break;
      }
    }
  }


ENFIN
Oscommerce passe tout cela à la fonction "tep_show_category()" qui afficher le code HTML correspondant :
(ligne 129)
CODE

  tep_show_category($first_element);


Conclusion : pour ne jamais afficher les sous-catégories, il ne faut jamais "exécuter" le code PHP du bloc B.
Ca se fait facilement en changeant la condition d'entrée dans le bloc de code :
REMPLACER (lignes 92-93)
CODE

  //------------------------
  if (tep_not_null($cPath)) {

PAR
CODE

  //------------------------
  if (false && tep_not_null($cPath)) {

=> Avec "false &&", la condition ne sera jamais vraie, on n'entrera jamais dans le bloc de code : les sous-catégories ne seront jamais affichées à gauche.
TheGame

J'ai essayé de remplacer:

CODE

  //------------------------
  if (tep_not_null($cPath)) {


par

CODE

  //------------------------
  if (false && tep_not_null($cPath)) {


Mais aucun changement. cry.gif
Celluloid
Dommage, parce qu'il n'y a aucune raison que cela ne marche pas ... sur une MS2-2 non traficotée smile.gif

1) le cache est-il activé ? Si oui, vider le cache (Administration, Outils, Cache Catégories => vider)
2) si problème persistant, copier-coller ici le contenu du fichier includes/column_left.php (entre les balises [code] et [/code] )
TheGame
Voici mon fichier includes/column_left.php

CODE

<?php
/*
  $Id: column_left.php,v 1.15 2003/07/01 14:34:54 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  if ((USE_CACHE == 'true') && empty($SID)) {
    echo tep_cache_categories_box();
  } else {
    include(DIR_WS_BOXES . 'categories.php');
  }

  if ((USE_CACHE == 'true') && empty($SID)) {
    echo tep_cache_manufacturers_box();
  } else {
    include(DIR_WS_BOXES . 'manufacturers.php');
  }

  require(DIR_WS_BOXES . 'whats_new.php');
  require(DIR_WS_BOXES . 'search.php');
  require(DIR_WS_BOXES . 'information.php');
?>


Celluloid
1) Et le cache ? il est activé ou pas ?
2) Dans includes/configure.php, que contient la ligne
CODE

define('DIR_WS_BOXES', ...)

?

PS : deux questions. deux réponses. merci. smile.gif
TheGame
1) Non le cache n'est pas activé blush.gif

2) Dans includes/configure.php

CODE

define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');


Celluloid
1) dans includes/boxes/categories.php
REMPLACER
CODE

  function tep_show_category($counter) {
    global $tree, $categories_string, $cPath_array;

PAR
CODE

  function tep_show_category($counter) {
    global $tree, $categories_string, $cPath_array;
    echo '******* JE SUIS LA !!! *********';

=> c'est censé foutre le bronx dans l'affichage, oui, c'est fait expres.

2) copier-coller ici le contenu de includes/header.php
TheGame
FICHIER includes/header.php
CODE


<?php
/*
  $Id: header.php,v 1.42 2003/06/10 18:20:38 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

// check if the 'install' directory exists, and warn of its existence
  if (WARN_INSTALL_EXISTENCE == 'true') {
    if (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/install')) {
      $messageStack->add('header', WARNING_INSTALL_DIRECTORY_EXISTS, 'warning');
    }
  }

// check if the configure.php file is writeable
  if (WARN_CONFIG_WRITEABLE == 'true') {
    if ( (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) && (is_writeable(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) ) {
      $messageStack->add('header', WARNING_CONFIG_FILE_WRITEABLE, 'warning');
    }
  }

// check if the session folder is writeable
  if (WARN_SESSION_DIRECTORY_NOT_WRITEABLE == 'true') {
    if (STORE_SESSIONS == '') {
      if (!is_dir(tep_session_save_path())) {
        $messageStack->add('header', WARNING_SESSION_DIRECTORY_NON_EXISTENT, 'warning');
      } elseif (!is_writeable(tep_session_save_path())) {
        $messageStack->add('header', WARNING_SESSION_DIRECTORY_NOT_WRITEABLE, 'warning');
      }
    }
  }

// check session.auto_start is disabled
  if ( (function_exists('ini_get')) && (WARN_SESSION_AUTO_START == 'true') ) {
    if (ini_get('session.auto_start') == '1') {
      $messageStack->add('header', WARNING_SESSION_AUTO_START, 'warning');
    }
  }

  if ( (WARN_DOWNLOAD_DIRECTORY_NOT_READABLE == 'true') && (DOWNLOAD_ENABLED == 'true') ) {
    if (!is_dir(DIR_FS_DOWNLOAD)) {
      $messageStack->add('header', WARNING_DOWNLOAD_DIRECTORY_NON_EXISTENT, 'warning');
    }
  }

  if ($messageStack->size('header') > 0) {
    echo $messageStack->output('header');
  }
?>
<!--

              




-->



<table cellspacing=0 cellpadding=0 width=100% height=100%>
<tr><td background=images/m35.gif>
  <table cellspacing=0 cellpadding=0 width=663 height=100% align=center>
   <tr><td valign=top>
    <table cellspacing=0 cellpadding=0>
     <tr><td width=251>
      <table cellspacing=0 cellpadding=0>
       <tr><td height=18></td></tr>
       <tr><td><a href=<?=tep_href_link('index.php')?>><img src=images/m02.gif width=220 height=85 border=0></a></td></tr>
      </table>
     </td>
     <td background=images/m03.gif width=58 height=103 valign=top>
      <table cellspacing=0 cellpadding=0>
       <tr><td height=36></td></tr>
       <tr><td style="padding-left: 16px">
  


       </td></tr>
      </table>
     </td>
     <td width=354 valign=top>
      <table cellspacing=0 cellpadding=0 align=right>
       <tr><td height=39></td></tr>
       <tr><td class=ch2><a href=<?=tep_href_link('specials.php')?> class=ml1>Promo</a><span class=ch1></span>|<span class=ch1></span><a href=<?=tep_href_link('contact_us.php')?> class=ml1>Contact</a><span class=ch1></span>|<span class=ch1></span><a href=<?=tep_href_link('account.php')?> class=ml1>Créer un compte</a><span class=ch1></span>|<span class=ch1></span><a href=<?=tep_href_link('login.php')?> class=ml1>S'identifier<td></tr>
       <tr><td height=10></td></tr>
       <tr><td>
        <table cellspacing=0 cellpadding=0>
         <tr><td width=125>
            


         </td>
         <td width=1 bgcolor=#A2A092></td>
         <td width=203 align=right><span class=ch3>Votre panier:</span> <a class=ml2 href=<?=tep_href_link('shopping_cart.php')?>><?=$cart->count_contents()?> articles</a></td></tr>
        </table>
       </td></tr>
      </table>
     </td></tr>
     <tr><td colspan=3><a href=<?=tep_href_link('index.php')?>><img src=images/b01.gif width=115 height=58 border=0></a><a href=<?=tep_href_link('products_new.php')?>><img src=images/b02.gif width=110 height=58 border=0></a><a href=<?=tep_href_link('account.php')?>><img src=images/b03.gif width=111 height=58 border=0></a><a href=<?=tep_href_link('shopping_cart.php')?>><img src=images/b04.gif width=110 height=58 border=0></a><a href=<?=tep_href_link('checkout_shipping.php')?>><img src=images/b05.gif width=91 height=58 border=0></a><img src=images/m07.gif width=126 height=58></td></tr>
     <tr><td colspan=3><img src=images/m08.gif width=663 height=11></td></tr>
     <tr><td colspan=3 style="padding-left: 4px"><a href=<?=tep_href_link('specials.php')?>><img src=images/m09.gif width=221 height=161 border=0></a><a href=<?=tep_href_link('products_new.php')?>><img src=images/m10.gif width=221 height=161 border=0><img src=images/m11.gif width=217 height=161 border=0></a></td></tr>
     <tr><td height=11></td></tr>
    </table>
   </td></tr>  
   <tr><td height=100% valign=top>
    <table cellspacing=0 cellpadding=0 width=663>
     <tr><td width=225 style="padding-right: 1px" class=bg2 valign=top>
      <table cellspacing=0 cellpadding=0 width=225 class=bg1>
       <tr><td height=12></td></tr>  
       <tr><td class=ch4><span class=ch5>CATEGORIES</span></td></tr>
       <tr><td height=20></td></tr>
       <tr><td class=ch4>
        <table cellspacing=0 cellpadding=0 width=159>


<?   // ---- CATEGORIES

  function tep_show_category($counter) {
    global $tree, $categories_string, $cPath_array;

   if(!$tree[$counter]['level']){              
                    
    $categories_string .= $categories_string ? '<tr><td colspan=2 background=images/m15.gif width=159 height=1></td></tr>' : '';            

    $categories_string .= '<tr><td colspan=2 height=20><img src=images/m14.gif width=6 height=5>   <a class=ml3 href=';
    
    if ($tree[$counter]['parent'] == 0) {
      $cPath_new = 'cPath=' . $counter;
    } else {
      $cPath_new = 'cPath=' . $tree[$counter]['path'];
    }
    $categories_string .= tep_href_link('index.php', $cPath_new) . '>';
// display categry name
    $categories_string .= $tree[$counter]['name'];
    $categories_string .= '</a></td></tr> ';
  
   }else{  // SUBCATEGORY
  
    $categories_string .= '<tr><td colspan=2 height=20><img src=images/m14.gif width=6 height=5>  ';

    for($i=0;$i<$tree[$counter]['le vel'];$i++)
     $categories_string .= '     ';
    
    $categories_string .= '     <a class=ml3 style="font-weight:normal;" href=';  
    if ($tree[$counter]['parent'] == 0) {
      $cPath_new = 'cPath=' . $counter;
    } else {
      $cPath_new = 'cPath=' . $tree[$counter]['path'];
    }
    $categories_string .= tep_href_link('index.php', $cPath_new) . '>-';
// display category name
    $categories_string .= $tree[$counter]['name'];
    $categories_string .= '</a></td></tr>';
   }  

    if ($tree[$counter]['next_id'] != false) {
      tep_show_category($tree[$counter]['next_id']);
    }  
  }



  define(TABLE_CATEGORIES, "categories");
  define(TABLE_CATEGORIES_DESCRIPTION, "categories_description");
  $categories_string = '';
  $tree = array();

  $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.parent_id = '0' 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'],
                                                '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 ($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.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'],
                                               '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;
      }
    }
  }
  $categories_string .=  '';
  tep_show_category($first_element);
  $categories_string .=  '';

  echo $categories_string;
?>

        </table>
       </td></tr>
       <tr><td><img src=images/m17.gif width=225 height=38></td></tr>
      </table>
     </td>
     <td bgcolor=#3a3a3a width=437 valign=top table border=1>

Celluloid
Bien !

J'ai une bonne et une mauvaise nouvelle.
La bonne nouvelle, c'est que si tu souhaites masquer les sous-catégories, tu n'as qu'à
REMPLACER dans includes/header.php
CODE

  //------------------------
  if ($cPath) {

PAR
CODE

  //------------------------
  if (false && tep_not_null($cPath)) {


La mauvaise nouvelle, c'est que ton "template" est une version bien remaniée d'oscommerce : bouts de code déplacés (comme ici includes/boxes/categories.php inclus à l'arrache dans header.php ), structure HTML modifiée pour y inclure en dur les images du template ...
Et de ce que je vois, je peux pas te dire avec certitude que ce "template" contient les dernières mises à jour de sécurité - surement pas celles de juillet 2006, certes- de novembre/décembre 2005 .

Conclusion : tu vas lutter pour obtenir rapidement de l'aide *efficace* pour ta version sur ce forum ...
=> Avec une MS2-2 de base, tu aurais résolu le problème en 15 mn (puisque ma réponse initiale était juste).
=> Là, on y a passé près d'1h20, et c'est une modification "mineure" ...

Vois les autres posts sur le forum concernant les templates graphiques types template-monster et vois en conséquence si tu ne gagnerais pas plus de temps à te faire aider par quelqu'un/un prestataire pour la partie "catalog" (en imaginant que la version admin est intacte et fonctionne comme une MS2-2) ...
Sinon, bon courage smile.gif

Voir notamment la réponse de Gnidhal dans ce sujet :
Kits graphiques et autres templates
TheGame
Merci beaucoup de ton aide.
Ca marche nikel.
A très Bientot wink.gif
Celluloid
Tu as le droit d'éditer ton premier post (édition complète) et de rajouter [RESOLU] devant le sujet smile.gif
Ceci est une version "bas débit" de notre forum. Pour voir la version complète avec plus d'informations, la mise en page et les images, veuillez cliquer ici.
Invision Power Board © 2001-2013 Invision Power Services, Inc.