Terminando…
Bueno, llegamos al final de este cursillo. Nos queda montar el esqueleto de nuestra página web. Vamos allá. Aquí esta el código:
Código:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="clases/clsidioma.asp"-->
<%
‘ Nuestra constante :-)
Const DEFAULT_LANGUAGE = "es"
Dim Idioma
Idioma = request.QueryString(“lang”)
If Idioma = “” then Idioma = Session(“Idioma”)
If Idioma =”” then Idioma = Trim(left(request.ServerVariables("HTTP_ACCEPT_LANGUAGE"),2))
‘ Si, viene vacia después de todo lo que ha pasado, pues le asignamos la constante
If Idioma = “” then Idioma = DEFAULT_LANGUAGE
‘ Creamos nuestro objeto para leer XML
Dim objIdioma
set objIdioma = new clsIdioma
Dim strError
‘ Fijaos como he hecho la estructura de directorios
‘ Dentro del directorio Idiomas hay tantos subdirectorios
‘ como idiomas haya. Y dentro de estas subcarpetas
‘ los archivos XML que quiera leer
strError = objIdioma.Load(Server.MapPath("idiomas/" & Idioma & "/general.xml"))
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><%=objIdioma.getIdioma("NombrePagina")%></title>
<link href="estilo.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="errores"><%=strError%></div>
<div id="contenedor">
<h1>
<%=objIdioma.getIdioma("NombrePagina")%>
</h1>
<%
Dim Menues
‘ Si os fijais vereis que lo usar como si
‘ fuera un recordset de toda la vida ;)
set Menues = objIdioma.getMenus()
‘ Si no esta vacio…
if not Menues is Nothing then
%>
<div id="nav">
<ul>
<%
‘ Me paseo por cada registro
do while not Menues.EOF
%>
<li><a href="<%=Menues("url")%>" target="<%=Menues("target")%>"><%=Menues("texto")%></a></li>
<%
Menues.moveNext()
loop
%>
</ul>
</div>
<%
end if
set Menues = nothing
‘ Lo mismo con los idiomas disponibles
Dim LangMenues
set LangMenues = objIdioma.getLangMenus()
if not LangMenues is Nothing then
do while not LangMenues.EOF
response.Write("<a href=""" & request.ServerVariables("SCRIPT_NAME") & "?lang=" & LangMenues("id") & """>")
response.Write("<img src=""" & LangMenues("imgUrl") & """ border=""0"" alt=""" & LangMenues("alt") & """ />")
response.Write("</a> ")
LangMenues.moveNext()
loop
end if
set LangMenues = nothing
%>
<div id="cuerpo">
<h2>
<%=objIdioma.getIdioma("tituloPaginaPrincipal")%>
</h2>
<blockquote>
<%=objIdioma.getIdioma("textoPaginaPrincipal")%>
</blockquote>
</div>
<div id="pie">
<%=objIdioma.getIdioma("piePagina")%>
</div>
</div>
</body>
</html>
<%
set objIdioma = nothing
%>
Como veis, es muy facil de entender. Os dejo a continuación el archivo CSS para que se vea en condiciones nuestra página web
Código:
body
{
text-align: center;
background: #B0BFC2;
color: #444;
}
#contenedor
{
text-align: left;
margin: 0 auto;
width: 700px;
background: #FFF;
}
h1
{
background: #D36832;
color: #FFF;
padding: 20px;
margin: 0;
border-bottom: 5px solid #387A9B;
}
blockquote {
background: #D36832;
color: #FFF;
border: #000000 thin dotted;
}
blockquote p {
padding:0.8em;
font-size:80%;
font-style:italic;
}
blockquote div#autor {
padding:0.6em;
text-align:right;
font-size:70%;
font-style:italic;
font-weight:bold;
}
blockquote div#obra {
color:#FFF;
padding-top:0.5em;
text-align:center;
font-size:120%;
font-weight:bold;
font-variant:small-caps;
text-transform:capitalize;
}
#nav
{
float: left;
width: 140px;
display: inline;
margin-left: 5px;
padding: 15px 0;
}
#nav ul
{
margin: 0;
padding: 0;
list-style-type: none;
text-align: right;
}
#nav li
{
padding: 0 10px 5px 0;
}
#cuerpo
{
float: left;
width: 475px;
margin-left: 45px;
padding: 15px 0;
}
#pie
{
clear: both;
background: #387A9B;
color: #fff;
padding: 5px 10px;
text-align: right;
font-size: 80%;
}
h2
{
margin-top: 0;
color: #B23B00;
font-weight: normal;
}
a:link
{
color: #175B7D;
}
a:visited
{
color: #600;
}
a:hover, a:active
{
color: #fff;
background: #175B7D;
}