ECMALL get_options 生成下拉菜單

$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>           

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章