function traer_opciones_menu($padre = "", $nivel = 0) { $cdb = new base(); $salida = ""; $seleccion = array("id", "url", "titulo", "acceso"); $limitantes[] = array("", "estatus", "!=", "0"); if ($padre != "") { $limitantes[] = array("and", "padre", "=", $padre); } else { $limitantes[] = array("and", "padre", "IS", $padre); } $tabla[] = "menu"; $cdb->set_referencia("posicion"); $cdb->set_forma("asc"); $respuesta = $cdb->seleccionar($seleccion, $limitantes, $tabla); if ($respuesta['codigo'] == 1) { if ($padre == "") { $salida .= "<ul class=nav >"; } else { $salida .= "<ul>"; } for ($i = 0; $i < count($respuesta['mensaje']); $i++) { $salida .= "<li><a href=\"" . $respuesta['mensaje'][$i]['url'] . "\" >" . $respuesta['mensaje'][$i]['titulo'] . "</a>"; $salida .= traer_opciones_menu($respuesta['mensaje'][$i]['id'], $nivel + 1); $salida .= "</li>"; } $salida .= "</ul>"; return $salida; } }
function encabezado($titulo, $acceso = "") { if ($acceso == "") { $cdb = new base(); $user = 1; $ahora = date('Y-m-d H:i:s'); $navegador = $_SERVER['HTTP_USER_AGENT']; $datos = array("url" => $titulo, "ip" => IpReal(), "navegador" => $navegador, "momento" => $ahora, "usuario" => $user); $cdb->insertar($datos, "visita", "1"); } $documento = ""; $gestor = fopen("http://{$_SERVER['SERVER_NAME']}/temas/gtcompra/vista.html", "r"); while (!feof($gestor)) { $documento .= fgets($gestor); } $notificacion = "<div class=sintio_notificacion><input id=correo_usuario type=text placeholder=\"Inscribete ingresando tu correo\" /><input id=enviar_suscripcion type=button value=Enviar></div>"; $documento = str_replace("Titulo Pagina", $titulo, $documento); $documento = str_replace("Menu Pagina", traer_opciones_menu(), $documento); echo $documento; if (!isset($_GET['ds'])) { echo $notificacion; } }
<nav><?php require_once "traer_opciones_menu.php"; echo traer_opciones_menu(); ?> </nav> <style type="text/css"> * { font-family:sans-serif; list-style:none; text-decoration:none; margin:0; padding:0; } .nav > li { float:left; } .nav li a { background:#0c9ba0; color:#FFF; display:block; border:1px solid; padding:10px 12px; } .nav li a:hover { background:#0fbfc6; } .nav li ul { display:none;