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 . '_' : ''));
}
}
}
$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 . '_' : ''));
}
}
}