zencart 自定义函数
-----------------------------------------------------------------------------------------------------------
---------------------------------列出目录 网址--------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
function zen_get_categories_names($categories_array = '', $parent_id = '0', $indent = '') {
global $db;
if (!is_array($categories_array)) $categories_array = array();
$categories_query = "select c.categories_id, cd.categories_name
from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
where parent_id = '" . (int)$parent_id . "'
and c.categories_id = cd.categories_id
and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'
order by sort_order, cd.categories_name";
$categories = $db->Execute($categories_query);
while (!$categories->EOF) {
$categories_array[] = array(zen_href_link(FILENAME_DEFAULT, 'cPath=' . $categories->fields['categories_id']),
$categories->fields['categories_name']);
if ($categories->fields['categories_id'] != $parent_id) {
$categories_array = zen_get_categories_names($categories_array, $categories->fields['categories_id'],'');
}
$categories->MoveNext();
}
return $categories_array;
}
?>
----------------------
<?php
foreach (zen_get_categories_names(array(array()),0 ,'') as $key => $value)
{
if (is_array($value))
{
print_r($value);
}
}
----------------------输出:
Array ( [0] => http://localhost/3/zencart151zh001/index.php?main_page=index&cPath=1 [1] => Jacke Damen ~ cafe racer damen ) Array ( [0] => http://localhost/3/zencart151zh001/index.php?main_page=index&cPath=2 [1] => Jacke Herren ~ outlet jacke )
------------------------------------------------------------------------------------------------