ECMALL get_options 生成下拉菜单

来源:互联网 发布:mybatis 打印完整sql 编辑:程序博客网 时间:2024/05/18 12:41

$this->assign('ad_pos', $this->_ad_pos_mod->get_options(-1, false));

 

 /**
     * 取得分类列表
     *
     * @param int $parent_id 大于等于0表示取某分类的下级分类,小于0表示取所有分类
     * @param bool $shown 只取要显示的分类
     * @return array
     */
    function get_list($parent_id = -1, $shown = false)
    {
        $conditions = "1 = 1";
        $parent_id >= 0 && $conditions .= " AND parent_id = '$parent_id'";
        $shown && $conditions .= " AND if_show = 1";

        return $this->find(array(
            'conditions' => $conditions,
            'order' => 'id',
   
        ));
    }
 
 function get_options($parent_id = -1, $shown = false)
    {
        $options = array();
        $rows = $this->get_list($parent_id, $shown);
        foreach ($rows as $row)
        {
            $options[$row['id']] = $row['pos_name']."[".$row['description']."]";
        }

        return $options;
    }

 

html:

 <select id="user_id" name="user_id"><option value="0">{$lang.select_pls}</option>{html_options options=$users selected=$user.user_id}</select>           

原创粉丝点击