zoukankan      html  css  js  c++  java
  • 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 )

    ------------------------------------------------------------------------------------------------

  • 相关阅读:
    选择排序
    迭代器使用过程中为什么抛出ConcurrentModificationException
    自定义实现的ArrayList以及自定义实现的Iterator迭代器
    单链表
    collections方法记录
    JDK1.9中关于集合的新方法
    请使用时间相关的API,计算一个人从出生到现在一共活了多少天?
    java中对象的向上转型和向下转型
    异常相关知识整理
    可变参数相关知识
  • 原文地址:https://www.cnblogs.com/alex-13/p/4386182.html
Copyright © 2011-2022 走看看