Aide - Recherche - Membres - Calendrier
Version complète : pb contrib all_categories
Forum osCommerce-fr > Adapter OsCommerce MS2 > Contributions
Racanierd
Bonjour,
j'ai installé la contrib all_categories, et dans le fichier all_categories.php je souhaiterais ajouter un code permettant d'obtenir un saut de ligne (un <br>) à partir de chaque nouvelle catégorie tout en conservant le retour à la ligne pour chaque sous-catégories. Je suppose que ce doit être quelque part dans cette boucle.
CODE
// Keep out parts category
        $excluded_parts_category_id = 28;


// Preorder tree traversal
  function preorder($cid, $level, $foo, $cpath) {
    global $categories_string, $HTTP_GET_VARS;

    if ($cid != 0) {
    // 1.7 Get the current path info
            $category_path = explode('_',$HTTP_GET_VARS['cPath']);
            $in_path = in_array($cid, $category_path);
            $this_category = array_pop($category_path);
            
      for ($i=0; $i<$level; $i++)
            // 1.7 only indent subcategories (top level are flush left)
                if ($i>0){
                $categories_string .=  '     ';
                }
                
                // 1.7 indicate the current category
                if ($this_category == $cid) {
                    $categories_string .=  tep_image(DIR_WS_IMAGES . '/arrow_green.gif', '');
                }
                
                // 1.7  don't link the current category        
                if ($this_category != $cid) {
                    $categories_string .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $cpath . $cid) . '">';
                }
    // 1.6 Are we on the "path" to selected category? If yes, use <b>
                if ($in_path) {
                    $categories_string .=  '<b>';
                }
                $categories_string .=  $foo[$cid]['name'];
                
                if ($in_path)
                    $categories_string .=  '</b>';
                
                // 1.7  don't link the current category
                if ($this_category != $cid) {
                    $categories_string .= '</a>';
                }
        // 1.4 SHOW_COUNTS is 'true' or 'false', not true or false

                $categories_string .= '<br>' ."\n";
                
        }

// Traverse category tree
            foreach ($foo as $key => $value) {
                if ($foo[$key]['parent'] == $cid) {
    //        print "$key, $level, $cid, $cpath<br>";
                    preorder($key, $level+1, $foo, ($level != 0 ? $cpath . $cid . '_' : ''));
                }
            }
  }


Racanierd
J'ai trouvé un bout de code dans un post de l'un des membres du forum, ce qui correspond à ce que je cherchais, à une nuance près, comment éviter qu'il affecte la 1ère catégorie ?

Rappel du code trouvé :
CODE
if ($foo[$cid]['parent'] == 0) {
                $categories_string .= '<br>';
                }


Le voici intégré dans mon code :
CODE
      for ($i=0; $i<$level; $i++)
            // 1.7 only indent subcategories (top level are flush left)
                
                if ($i>0){
                $categories_string .=  '     ';
                }
                if ($foo[$cid]['parent'] == 0) {
                $categories_string .= '<br>';
                }


Est-il mal placé ? manque-t-il une info ?
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.