Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //dados que vão para a view
- $categorias .= '<div id="drillcrumb"></div>';
- $categorias .= '<div id="drillmenu1" class="drillmenu">';
- $categorias .= $this->_listar_categorias(0);
- $categorias .= '<br style="clear: left" />';
- $categorias .= '</div>';
- $dados['categorias'] = $categorias;
- //função chamada no controller anterior
- function _listar_categorias($pai)
- {
- $this->db->select("id, nome, pai, ativo");
- $this->db->from("categorias");
- $this->db->where("pai", $pai);
- $this->db->where("ativo", "S");
- $this->db->order_by("nome", "ASC");
- $dados = $this->db->get();
- $html = '';
- if($dados->num_rows() > 0) {
- $html .= '<ul id="tree-view" class="treeview-black">' . "\n";
- foreach($dados->result() as $res) {
- $html .= '<li><span id="'.$res->id.'">' . $res->nome . '</span>' . "\n";
- //recursiva
- $html .= $this->_listar_categorias($res->id);
- $html .= '</li>' . "\n";
- }
- $html .= '</ul>' . "\n";
- } else {
- return FALSE;
- }
- return $html;
- }
Add Comment
Please, Sign In to add comment