<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cultura Digital#Blog &#187; Desarrollo web</title>
	<atom:link href="http://blog.culturadigital.org/temas/tecnologia/desarrollo-web/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.culturadigital.org</link>
	<description>Tener algo que decir; y decirlo.</description>
	<lastBuildDate>Mon, 08 Mar 2010 04:21:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mejora visualmente tus kbd con CSS</title>
		<link>http://blog.culturadigital.org/tecnologia/desarrollo-web/mejora-visualmente-tus-kbd-con-css</link>
		<comments>http://blog.culturadigital.org/tecnologia/desarrollo-web/mejora-visualmente-tus-kbd-con-css#comments</comments>
		<pubDate>Thu, 25 Feb 2010 19:03:49 +0000</pubDate>
		<dc:creator>J.A.Cobo</dc:creator>
				<category><![CDATA[Desarrollo web]]></category>
		<category><![CDATA[Diseño web]]></category>
		<category><![CDATA[Trabajos]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[estilo]]></category>
		<category><![CDATA[kbd]]></category>

		<guid isPermaLink="false">http://blog.culturadigital.org/?p=821</guid>
		<description><![CDATA[Hace tiempo que no publico nada en el blog y hoy, tras volver a mejorar el estilo visual para contenidos que usan la etiqueta kbd (keyboard) en algunos de mis trabajos, he decidido publicar el estilo CSS que utilizo y que, personalmente, me gusta bastante como queda.
Parte de la regla principal está inspirada en el [...]]]></description>
			<content:encoded><![CDATA[<p>Hace tiempo que no publico nada en el blog y hoy, tras volver a mejorar el estilo visual para contenidos que usan la etiqueta <span class="tt">kbd</span> (<dfn title="Teclado, en inglés" xml:lang="en">keyboard</dfn>) en algunos de mis trabajos, he decidido publicar el estilo CSS que utilizo y que, personalmente, me gusta bastante como queda.<br />
Parte de la regla principal está inspirada en el estilo por defecto que usa Wikipedia, pero ciertamente la adapté a mi gusto y añadí más efectos como el estado <em>sobre</em>, bordes redondeados, fuentes y colores&#8230; si sigo casi que es la regla entera <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<h4>Ejemplo</h4>
<p>En definitiva, el estilo para la etiqueta kbd y que se puede apreciar ampliamente en la sección <a href="http://blog.culturadigital.org/accesibilidad">Accesibilidad</a> queda así:</p>
<p><kbd>Alt</kbd></p>
<h4>Reglas CSS</h4>
<p>Las reglas CSS son las siguientes:</p>
<p>En mi <strong>basic.css</strong>:<br />
Una regla genérica y común anterior:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="css" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;">pre<span style="color: #00AA00;">,</span> code<span style="color: #00AA00;">,</span> tt<span style="color: #00AA00;">,</span> kbd <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span>		<span style="color: #933;">0.87em</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span>		Monaco<span style="color: #00AA00;">,</span> <span style="color: #ff0000;">'Andale Mono'</span><span style="color: #00AA00;">,</span> 
				<span style="color: #ff0000;">'Bitstream Vera Sans Mono'</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">monospace</span> !important<span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span>			<span style="color: #cc00cc;">#008000</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>* <strong>Nota</strong>: Aunque <em>Monaco</em> me gusta mucho, antes usaba la nueva fuente monoespaciada de Windows Vista para edición de código <em>Consolas</em>, pero su tamaño varía mucho con el resto de fuentes alternativas. Creo que también hay que tener cuidado, aunque no recuerdo cierto, con <em>Andale Mono</em>.<br />
&#8230;aunque siempre se puede recurrir a <span class="tt">@font-face {}</span> para usar una fuente propia o incluso a <em><a href="http://www.google.es/search?q=cufon" title="Buscar en Google sobre la técnica cufon">cufon</a></em>.</p>
<p>Personalización para el estilo final:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="css" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;">kbd <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> 		<span style="color: #cc66cc;">0</span> <span style="color: #933;">0.5em</span> <span style="color: #933;">0.5em</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> 		<span style="color: #cc66cc;">0</span> <span style="color: #933;">0.5em</span> <span style="color: #933;">0.1em</span> <span style="color: #933;">0.25em</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> 			<span style="color: #933;">4em</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> 		<span style="color: #933;">4em</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> 		<span style="color: #933;">4em</span><span style="color: #00AA00;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span>		<span style="color: #cc00cc;">#EEE</span> <span style="color: #993333;">none</span> <span style="color: #993333;">repeat</span> <span style="color: #993333;">scroll</span> <span style="color: #933;"><span style="color: #cc66cc;">0</span>%</span> <span style="color: #933;"><span style="color: #cc66cc;">0</span>%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span>			<span style="color: #933;">0.23em</span> <span style="color: #993333;">outset</span> <span style="color: #cc00cc;">#DDD</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-bottom-color</span><span style="color: #00AA00;">:</span>	<span style="color: #cc00cc;">#BBB</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-right-color</span><span style="color: #00AA00;">:</span>	<span style="color: #cc00cc;">#BBB</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> 		<span style="color: #933;">0.3em</span><span style="color: #00AA00;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span>			<span style="color: #000000; font-weight: bold;">black</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> 		<span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">white-space</span><span style="color: #00AA00;">:</span>		<span style="color: #993333;">nowrap</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
kbd<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> 		<span style="color: #cc66cc;">0</span> <span style="color: #933;">0.75em</span> <span style="color: #933;">0.75em</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> 		<span style="color: #cc66cc;">0</span> <span style="color: #933;">0.53em</span> <span style="color: #933;">0.13em</span> <span style="color: #933;">0.28em</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span>			<span style="color: #933;">0.1em</span> <span style="color: #993333;">outset</span> <span style="color: #cc00cc;">#DDD</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-bottom-color</span><span style="color: #00AA00;">:</span>	<span style="color: #cc00cc;">#EEE</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-right-color</span><span style="color: #00AA00;">:</span>	<span style="color: #cc00cc;">#EEE</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span>			<span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Básicamente cambiamos los bordes inferior y derecho a otro color para el efecto de sombreado, además del tamaño para el efecto <em>pulsada</em>. Luego ajustamos los espaciados y márgenes para que, al reducir o aumentar el tamaño de los bordes, el del botón no varíe -al menos demasiado (nota siguiente)-.</p>
<p>Pueden existir problemas al usar medidas relativas&#8230; pero yo al menos ya me he acostumbrado a ellas y prácticamente no diseño nada en base a píxeles.<br />
&#8230;es algo arriesgado, sobre todo con navegadores poco estándares, pero diseñando de un modo más flexible y aceptando las variaciones de estos últimos -que las tienen con o sin píxeles- al final el resultado es casi más gratificante. Los píxeles quedan casi en exclusiva para elementos que no redimensionen o que solo lo hagan dentro de unos límites conocidos. Por ejemplo un elemento que sepas solo se ampliará o reducirá por un lado y dejes un espacio para una imagen de tamaño fijo. No obstante, incluso en casos así se sigue pudiendo prescindir de ellos perfectamente.</p>
<p>Además ajustamos el texto, como en los teclados, un poco a la parte superior izquierda, un efecto sutil en teclas pequeñas y visible en las grandes.</p>
<h5>Jugando un poco, más ejemplos</h5>
<p>Aquí viene otra de las bondades de los tamaños relativos: aunque no sean medidas exactas de teclas, las teclas grandes -con más texto- se autoexpanden. Y permiten jugar un poco con su contenido aunque de forma menos semántica. En concreto, añadiendo texto y ajustando la autoexpansión, se le da sentido a las teclas cuando no se usa CSS. Por ejemplo:<br />
Para <kbd>Ctrl</kbd> y <kbd>Alt</kbd>, el mismo tamaño del texto es suficiente, pero para mayúsculas simples (shift) podemos o añadir la palabra inglesa, u ocultarla mediante algo de CSS de presentación -del que no me gusta pero bueno- y conseguir el tamaño deseado.</p>
<p><kbd>&uArr; Shift</kbd><br />
Versión ocultando <em>shift</em> sin extras:<br />
<kbd>&uArr; <span style="visibility:hidden;">Shift</span></kbd><br />
Una tecla más real, mayúsculas corta:<br />
<kbd><span style="font-size:1.4em;">&uArr;</span> <span style="visibility:hidden; letter-spacing:-2em;">Shift</span></kbd><br />
Mayúsculas larga:<br />
<kbd><span style="font-size:1.4em;">&uArr;</span> <span style="visibility:hidden; letter-spacing:0.8em;">Shift</span></kbd></p>
<p>Espacio:<br />
<kbd><span style="visibility:hidden; letter-spacing:3em;">Shift</span></kbd></p>
<p>Retroceso:<br />
<kbd><span style="font-size:1.4em;">&larr;</span><span style="visibility:hidden;">return</span></kbd><br />
 <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Bueno, ahí queda por si le gusta o interesa a alguien.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.culturadigital.org/tecnologia/desarrollo-web/mejora-visualmente-tus-kbd-con-css/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SVG: Un ejemplo más de su potencial</title>
		<link>http://blog.culturadigital.org/tecnologia/desarrollo-web/svg-un-ejemplo-mas-de-su-potencial</link>
		<comments>http://blog.culturadigital.org/tecnologia/desarrollo-web/svg-un-ejemplo-mas-de-su-potencial#comments</comments>
		<pubDate>Tue, 17 Nov 2009 16:35:23 +0000</pubDate>
		<dc:creator>J.A.Cobo</dc:creator>
				<category><![CDATA[Desarrollo web]]></category>
		<category><![CDATA[Diseño web]]></category>
		<category><![CDATA[animación]]></category>
		<category><![CDATA[estándares-web]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://blog.culturadigital.org/?p=758</guid>
		<description><![CDATA[Como siempre, una breve introducción:
Como a no poca gente creo, me encantan los créditos finales de The Bourne Identity (El caso Bourne) y la saga en general -creo que es obvio que Extreme Ways tiene mucho que ver   -.
Hace poco vi algunos vídeos en Youtube para recrear los efectos de los créditos desde [...]]]></description>
			<content:encoded><![CDATA[<p>Como siempre, una breve introducción:</p>
<p>Como a no poca gente creo, me encantan los créditos finales de <strong>The Bourne Identity</strong> (<em>El caso Bourne</em>) y la saga en general -creo que es obvio que <em title="Extreme Ways del álbum 18 de Moby">Extreme Ways</em> tiene mucho que ver <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  -.<br />
Hace poco vi algunos vídeos en Youtube para <strong>recrear los efectos de los créditos</strong> desde diferentes aplicaciones pero sobre todo con <em>After Effects</em>, que por cierto es genial, y en ese mismo instante pensé: vamos a demostrar que no necesitamos Flash para hacer lo mismo de forma estándar, es decir: <strong>con SVG</strong>.</p>
<h4>Ejemplo de créditos finales Bourne con SVG</h4>
<p>Anoche realicé mi primera aproximación en apenas una hora y los resultados prometían mucho. Debo aclarar que solo es eso: una aproximación, además de que no estoy muy puesto aún en la animación declarativa -nativa- de SVG ya que solo está soportada por Opera, Safari creo, y poco más. Normalmente yo utilizo scripting pero con el tiempo y el aumento de soporte todo pasará a ser declarativa, en su mayor parte al menos.</p>
<p>Lo que quiero decir es que estos han sido mis primeros pasos en animación declarativa SVG, no está optimizado ni acabado, solo pretende mostrar el potencial de SVG.</p>
<h4>Resultado</h4>
<p class="alert"><strong>Muy importante</strong>: Como decía, la animación declarativa solo está soportada -que yo sepa hasta ahora- en Opera y Safari, no sé si webkit en general como por ejemplo Chrome. Por lo tanto necesitas un navegador compatible para ver la animación de este SVG, aunque no de su contenido para ver como funciona.</p>
<p>Nota: <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  Es muy recomendable escuchar de fondo, sobre todo el comienzo, el tema «<strong>Extreme Ways</strong>» de los créditos; es del álbum, estupendo por cierto, «18», de «Moby», y aunque no lo he mirado creo recordar que se puede hacer también con animación SVG.<br />
<object data="http://blog.culturadigital.org/media/2009/11/bourne2.svg" type="image/svg+xml"><img src="http://blog.culturadigital.org/media/2009/11/bourne2.svg" alt="The Bourne Identity end credits" title="The Bourne Identity end credits" class="aligncenter size-full wp-image-759" /></object></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.culturadigital.org/tecnologia/desarrollo-web/svg-un-ejemplo-mas-de-su-potencial/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SVG: A vueltas con los Estándares</title>
		<link>http://blog.culturadigital.org/tecnologia/desarrollo-web/svg-a-vueltas-con-los-estandares</link>
		<comments>http://blog.culturadigital.org/tecnologia/desarrollo-web/svg-a-vueltas-con-los-estandares#comments</comments>
		<pubDate>Fri, 23 Oct 2009 20:10:36 +0000</pubDate>
		<dc:creator>J.A.Cobo</dc:creator>
				<category><![CDATA[Desarrollo web]]></category>
		<category><![CDATA[estándares-web]]></category>
		<category><![CDATA[SVG]]></category>

		<guid isPermaLink="false">http://blog.culturadigital.org/?p=717</guid>
		<description><![CDATA[La potencia de SVG -estándar de gráficos escalables vectoriales-, por ejemplo, para generar mapas con datos dinámicos:

Battleground Europe Tools &#8211; Pantallazo del MapViewer en la versión 39beta.

Me he encontrado de repente sorprendido porque aún no había escrito nada sobre SVG&#8230; con lo inmerso que estoy en ello ahora mismo en relación a las Battleground Europe [...]]]></description>
			<content:encoded><![CDATA[<p>La potencia de SVG -estándar de gráficos escalables vectoriales-, por ejemplo, para generar mapas con datos dinámicos:</p>
<div class="headerImg"><object data="http://www.1spanishcompany.co.uk/ftp-fotos/Covi/1SCTools/screenshots/BeTools.MapViewer.v0.39.jpg" type="image/jpeg" height="200px" width="100%"><param name="background-color" value="#222" /><param name="background-position" value="47% 15%" /><param name="background-border" value="1px solid #222"/><param name="border-radius" value="0.25em"/></object>
<p class="opacity7">Battleground Europe Tools &#8211; <a href="http://1spanishcompany.co.uk/ftp-fotos/Covi/1SCTools/screenshots/Pantallazo-Map%20Viewer.v38.jpg" title="Ver imagen">Pantallazo</a> del MapViewer en la versión 39beta.</p>
</div>
<p>Me he encontrado de repente sorprendido porque aún no había escrito nada sobre SVG&#8230; con lo inmerso que estoy en ello ahora mismo en relación a las <a href="http://betools.culturadigital.org" title="Sitio de las BeTools">Battleground Europe Tools</a>; una aplicación de monitorización para jugadores de <a href="http://battlegroundeurope.com">Battleground Europe</a> y que está centrada en la creación de un mapa lo más parecido al del juego, para poder seguir el desarrollo de la campaña online y sin necesidad de entrar en él. &#8230;de hecho, tengo una sección en el blog sobre el proyecto: <a href="http://blog.culturadigital.org/search/1sctools" title="buscar contenido relacionado">BE/1SCTools</a>.</p>
<p>Para no enrollarme mucho más, solo voy a dejar unas capturas del potencial de SVG como estándar para gráficos vectoriales y escalables en la web; es decir, en lugar de formatos o tecnologías propietarias como por ejemplo gif, flash&#8230; y/o no nativos como este último. Además sin necesidad de plugins, como el de Adobe por ejemplo, y sin <a href="http://blog.culturadigital.org/tecnologia/desarrollo-web/svg-un-ejemplo-mas-de-su-potencial">animaciones declarativas</a> ya que aún están muy poco soportadas, sustituyendo las mismas con Javascript, en este caso Ecmascript.</p>
<h4>Capturas Battleground Europe Tools</h4>
<p>v.39beta:<br />
<img src="http://www.1spanishcompany.co.uk/ftp-fotos/Covi/1SCTools/screenshots/BeTools.MapViewer.v0.39.jpg" alt="Map Viewer - v.39b" /></p>
<p><img src="http://1spanishcompany.co.uk/ftp-fotos/Covi/1SCTools/screenshots/Pantallazo-Map%20Viewer.v38.jpg" alt="Map Viewer - v.38" /></p>
<p><img src="http://1spanishcompany.co.uk/ftp-fotos/Covi/1SCTools/screenshots/Pantallazo-Map%20Viewer.2.v38.jpg" alt="Map Viewer (2) - v.38" /></p>
<p><img src="http://1spanishcompany.co.uk/ftp-fotos/Covi/1SCTools/screenshots/homeMapZoom.jpg" alt="Home - v.38" /></p>
<h4>Scripting: Javascript, Ecmascript, DOM&#8230;</h4>
<p>En el sentido del <em>scripting</em>, he aprendido mucho gracias, paradójicamente, a las pocas, por no decir ninguna, librerías Javascript que trabajan con el DOM de XML&#8230; o al menos de SVG en concreto. Y me refiero muy en parte a jQuery que desde luego hace lo que indica en su eslogan pero lo cierto es que se queda corta en el sentido global de extender y mejorar Javascript -como ya hace comentaba Anieto2K-. Es decir, por ejemplo mootools se abstrae más del tipo de documento o del DOM en este caso para montar un framework genérico que extienda y mejore de verdad Javascript&#8230; lo que ellos denominan «como debería ser Javascript».</p>
<p>He de decir que en este caso me ha sorprendido mucho mucho Prototype, el primer framework Javascript que usé en los albores de AJAX en la web 2.0, e imagino que es debido a su sólida génesis. De ahí que ni haya crecido como otras librerías&#8230; ni se haya desvirtuado que es lo bueno.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.culturadigital.org/tecnologia/desarrollo-web/svg-a-vueltas-con-los-estandares/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XHTML: Object en lugar de img</title>
		<link>http://blog.culturadigital.org/tecnologia/desarrollo-web/xhtml-object-en-lugar-de-img</link>
		<comments>http://blog.culturadigital.org/tecnologia/desarrollo-web/xhtml-object-en-lugar-de-img#comments</comments>
		<pubDate>Thu, 08 Oct 2009 16:43:24 +0000</pubDate>
		<dc:creator>J.A.Cobo</dc:creator>
				<category><![CDATA[Desarrollo web]]></category>
		<category><![CDATA[Diseño web]]></category>
		<category><![CDATA[estándares-web]]></category>
		<category><![CDATA[img]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[XHTML]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://blog.culturadigital.org/?p=648</guid>
		<description><![CDATA[En una entrada anterior comentaba las bondades de jQuery para hacer compatible el uso, por ejemplo, de un objeto en XML (XHTML) con navegadores que no lo soportaran, para aprovechar su potencial y crear imágenes bonitas de cabecera sin marcado no válido.
Quedó algo confuso desde el punto de vista de usar objetos; ahora pretendo concretar [...]]]></description>
			<content:encoded><![CDATA[<p>En una entrada anterior comentaba las bondades de jQuery para hacer compatible el uso, por ejemplo, de un objeto en XML (XHTML) con navegadores que no lo soportaran, para aprovechar su potencial y crear imágenes bonitas de cabecera sin marcado no válido.<br />
Quedó algo confuso desde el punto de vista de usar objetos; ahora pretendo concretar e ilustrar la idea del <strong>potencial de <tt>&lt;object&gt;</tt> (estándar del W3C) frente <tt>&lt;img&gt;</tt></strong>.</p>
<h4>Lo fundamental: diseñar en base a estándares</h4>
<p>La cuestión fundamental es: &lt;object&gt; nos da muchísimas más posibilidades y es más flexible que &lt;img&gt;; además es estándar, compatible con los navegadores actuales y con soporte para mucho mucho tiempo en el futuro.</p>
<p>La funcionalidad es la misma prácticamente que con la etiqueta propietaria de Netscape (img) usado de forma básica, pero ésta es extensible de mil y una maneras ya que se pueden usar parámetros que se abstraen del marcado estructural, y además es mucho más flexible y potente para contenido alternativo en navegadores que no lo soporten.</p>
<p>Es más estándar y coherente, por lo tanto más semántica, por ejemplo se puede establecer el mime type del objeto, etc. O sea, proporciona más información al navegador que, en teoría, debería redundar en un mayor rendimiento y menos coste de proceso.<br />
<strong>Es decir, todo son beneficios</strong>.</p>
<h5>¿Por qué resistirse?</h5>
<p>Existe un ámbito de ciertas opiniones clásicas que se escudan en la usabilidad y que saltan a la palestra siempre que se habla de Estándares web, de marcado basura, obsoleto, Flash, soporte Internet Explorer y profesionalidad; en especial cuando al parecer se ejerce intrusismo laboral y se presupone falta de experiencia.<br />
En referencia a esta última cuestión: No entiendo porqué les parece un sacrilegio olvidar de una vez a Internet Explorer 6 e inferiores, y por añadidura prácticamente el HTML clásico y obsoleto. En mi opinión diría que ya está bien y basta de dar soporte a un software con más de diez años y 5 sin actualizarse por no decir 7. Eso, es una aberración obvia en el desarrollo -y soporte- de software y no hubiera pasado nunca si su propietario no fuera Microsoft.</p>
<h6>Profesionalidad o pereza</h6>
<p>No, no es dar al cliente algo que funcione seguro, se trata de ser profesional; y ser profesional significa trabajar bien y superar las dificultades -entiendo yo, claro-, no hacer chapuzas de las que tenemos muchos ejemplos, ejemplos profesionales: web del Congreso, de Telefónica (ver ejemplo de la copia para promoción IPhone: Apple con Javascript válido y Telefónica con Flash xD) y algunas de Microsoft&#8230;</p>
<p>Quiero decir, SÍ es posible diseñar en base a los estándares y que tu diseño funcione, por ejemplo, en Internet Explorer -no me refiero al 6 en exclusiva- sin tener que escribir marcado basura, propietario u obsoleto. Otra cosa es pasar del tema, cobrar un pastón pero seguir siendo un chapucero, aun teniendo quinientos mil títulos académicos.</p>
<p>&#8230;y tampoco me creo que porque se use un sistema de gestión mastodóntico -administración pública- sea imposible proporcionar salidas de documentos válidas. Y si es el caso, si han migrado y actualizado la administración, deberían haber migrado también ese sistema&#8230; por que no será por falta de dinero para hacerlo.</p>
<h4>Ejemplos</h4>
<p>Como mencionaba, en el ejemplo de una imagen de cabecera bonita la <em>tendencia natural</em> es usar una división, aplicar estilos incrustados e insertar una imagen de fondo. La solución directa también podría ser diseñar dos versiones o más de una imagen, como ocurre en Wordpress cuando subes medios o casi en cualquier CMS.<br />
Bien&#8230; <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  rentable no es que sea mucho la verdad, eso sin contar con que por ejemplo quieras posicionar esa imagen de mil formas distintas: ¿una versión para cada caso o estilo que quieras aplicar?<br />
¿Porqué tener 20 versiones de la misma imagen para solo aplicar estilos?</p>
<p>La solución, en mi opinión obvia, es usarla como fondo y aplicar CSS. El problema a superar como decía es usar marcado válido, estructural y semántico. Ese es el problema que hay superar y ser profesional.</p>
<h5>Ejemplo no profesional o falto de recursos</h5>
<h6>Lo más terrorífico: tengo mil versiones para una imagen</h6>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="xml" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> </span>
<span style="color: #009900;">		<span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;mi versión de imagen, de entre unas 4/5 para aplicar un estilo caprichoso&quot;</span> </span>
<span style="color: #009900;">		<span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;Mi contenido alternativo se reduce a esta patatilla.&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;">&lt;br</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		Cristina Scabbia de Lacuna Coil.
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Si bueno&#8230; puedes incrustar estilos, javascript&#8230; o incluso podría no ser ni javascript intrusivo y CSS externo pero es muy muy fácil caer en la clasitis por ejemplo; sin contar con que img se cae en XHTML 2.0, y se caerá de todo en un futuro muy cercano, y sus limitaciones obvias.</p>
<h6>Estilos incrustados</h6>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="xml" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;headerImg&quot;</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;height:200px; background:#333 url(http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg) </span>
<span style="color: #009900;">	no-repeat 0 30%;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Cristina Scabbia de Lacuna Coil.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Algo es algo, al menos eliminamos la etiqueta imagen, las posibles versiones de una imagen y pasamos a usar una sola. Igualmente se nos va al garete sin CSS.</p>
<h5>Como tengo recursos, puedo ser estándar</h5>
<p>Esto es y debería ser la base. Que un maquetador se dedique a hacer las cosas correctamente, como mandan los cánones -en este caso los estándares web-; tener una versión portable y mantenible venga quien venga después; jueguen como quieran jugar después con los objetos y les den la salida que prefieran. Como hemos dicho mil veces: abstracción de la estructura, en este caso frente al diseño visual:</p>
<h6>Object</h6>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="xml" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;headerImg&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;object</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg&quot;</span> </span>
<span style="color: #009900;">		<span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;image/jpeg&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;200px&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;background-position&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;0% 30%&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/object<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Cristina Scabbia de Lacuna Coil.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Cojonudo:<br />
Por lo pronto, funciona, aunque no del todo bien, sin CSS, o sea de forma básica. Podemos jugar con los parámetros del objeto desde cualquier lenguaje de servidor que parsee el HTML, con Javascript&#8230; el caso es que se abstrae del estilo visual.<br />
Es coherente y semántico ya que proporciona información a los renderizadores: navegadores, etc.</p>
<p>Por ejemplo les dice que es una imagen/jpeg y se supone que en un futuro si no ya, da la posibilidad a los desarrolladores de navegadores web optimizar su funcionamiento y hacerlos más rápidos, sino ya desarrollar plugins específicos para imágenes, en concreto si tienen transparencias o no (png, gif vs jpeg, bmp&#8230;)&#8230; bff, y muchas cosas más imagino.<br />
Es decir, todo lo que sea dar información concreta sobre los elementos del documento es beneficio y renderización optimizada del navegador, algo que creo que se pierde, y se perdía, con HTML que normalmente es muy poco semántico, hasta ahora al menos.</p>
<h4>Casos probados</h4>
<h5>Todo funcional, con Javascript y CSS al vuelo</h5>
<p>Usando Javascript para gestionar el objeto:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="xml" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;headerImg&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;object</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg&quot;</span> </span>
<span style="color: #009900;">		<span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;image/jpeg&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;200px&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;background-position&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;0% 30%&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/object<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Cristina Scabbia de Lacuna Coil.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<div class="headerImg"><object data="http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg" type="image/jpeg" height="200px" width="100%"><param name="background-position" value="0% 30%" /></object>
<p>Cristina Scabbia de Lacuna Coil.</p>
</div>
<p>Vamos a jugar un poco con la imagen, no necesito más versiones de la misma, no necesito CSS incrustado, solo los parámetros del objeto que para eso están:<br />
<em>En este caso se gestiona con Javascript (jQuery) generando, eso sí, CSS al vuelo, pero como digo&#8230; es un proceso externo al marcado que es de lo que se trata.</em></p>
<p><tt>param name="background-position" value="50% 30%"</tt>:</p>
<div class="headerImg"><object data="http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg" type="image/jpeg" height="200px" width="100%"><param name="background-position" value="50% 30%" /></object>
<p>Cristina Scabbia de Lacuna Coil.</p>
</div>
<p><tt>param name="background-position" value="70% 70%"</tt>:</p>
<div class="headerImg"><object data="http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg" type="image/jpeg" height="200px" width="100%"><param name="background-position" value="70% 70%" /></object>
<p>Cristina Scabbia de Lacuna Coil.</p>
</div>
<p><tt>param name="background-color" value="red"</tt>:</p>
<div class="headerImg"><object data="http://nop" type="image/jpeg" height="200px" width="100%"><param name="background-position" value="70% 70%" /><param name="background-color" value="red" /></object>
<p>Cristina Scabbia de Lacuna Coil.</p>
</div>
<p><tt>param name="background-border" value="5px solid blue"</tt>:</p>
<div class="headerImg"><object data="http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg" type="image/jpeg" height="200px" width="100%"><param name="background-position" value="70% 70%" /><param name="background-border" value="5px solid blue" /></object>
<p>Cristina Scabbia de Lacuna Coil.</p>
</div>
<p><tt>param name="background-position" value="50% 0"</tt><br />
<tt>param name="background-border" value="1px solid blue"</tt><br />
<tt>param name="border-radius" value="3em 3em 0 0"</tt>:</p>
<div class="headerImg"><object data="http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg" type="image/jpeg" height="200px" width="100%"><param name="background-position" value="50% 0" /><param name="background-border" value="1px solid blue" /><param name="border-radius" value="3em 3em 0 0" /></object>
<p>Cristina Scabbia de Lacuna Coil.</p>
</div>
<p>¿Más pequeña?<br />
<tt>&lt;object [...]height="100px" width="50%"[...]</tt><br />
<tt>param name="background-position" value="50% 0"</tt><br />
<tt>param name="background-border" value="1px solid blue"</tt><br />
<tt>param name="border-radius" value="3em 3em 0 0"</tt>:</p>
<div class="headerImg"><object data="http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg" type="image/jpeg" height="100px" width="50%"><param name="background-position" value="50% 0" /><param name="background-border" value="1px solid blue" /><param name="border-radius" value="3em 3em 0 0" /></object>
<p>Cristina Scabbia de Lacuna Coil.</p>
</div>
<h6>Conclusión</h6>
<p>Con imagen (<tt>&lt;img&gt;</tt>) es inevitable o caer en clasitis o establecer atributos no estándares (<em>hacks</em>). Además se hace trabajar al navegador con cuestiones raras que no tiene porqué entender; es decir: debe intentar buscar atributos, por ejemplo rel -<em class="x-small">que se usa mucho y mal para hacks ya que su función no es ni por asomo esa salvo contadas excepciones</em>- que no concuerdan con nada de lo que conoce. Cuando si usamos un objeto, sabe perfectamente de qué se trata, lo renderiza y punto porque él no se encarga de gestionar sus parámetros; al menos y que yo sepa en este caso (mime type: imagen/jpeg), no sé exactamente como se comportan con otros objetos pero en cualquier caso les ayudamos a comportarse mejor porque concretamos un medio.</p>
<p>Alguien puede pensar que simplemente es una pasarela para atributos CSS, pero no obstante es igual de válido que con imagen (van a comportarse de la misma manera aplicando clases y reglas CSS) y te ofrece además estas posibilidades: gestionarlo con cualquier lenguaje sin marcado no válido, inventado o extra. Además, tu marcado será válido también para XML, lo que lo convierte en portable, estándar y por lo tanto mantenible, y compatible con el pasado y futuro.</p>
<p><strong>En resumen</strong>: Es por lo que precisamente, actualmente el W3C mantiene <tt>&lt;object&gt;</tt> en el estándar para elementos multimedia frente a la simpleza y pobreza de <tt>&lt;img&gt;</tt> de Netscape. Y obviamente porque es un elemento multimedia, claro.</p>
<h6>¿No es demasiado complicado?</h6>
<p>No nos equivoquemos, object puede ser tan simple como img:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="xml" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg&quot;</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;25%&quot;</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;Cristina Scabbia, Lacuna Coil&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;object</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg&quot;</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;25%&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	Cristina Scabbia, Lacuna Coil
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/object<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p><img src="http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg" width="25%" alt="Cristina Scabbia, Lacuna Coil" /><br />
<object data="http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg" width="25%">Cristina Scabbia, Lacuna Coil</object><br />
Pero es aún mejor, <em>potencial del contenido alternativo</em> y parámetros propios:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="xml" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;object</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;image/jpeg&quot;</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;no existo&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;25%&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;italic&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Tu navegador no puede mostrar esta imagen de <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;http://es.wikipedia.org/wiki/Cristina Scabbia&quot;</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Cristina Scabbia en Wikipedia&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Cristina Scabbia, Lacuna Coil<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
	cantando con su característico gesto apasionado, bajo la tenue iluminación azul del escenario.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/object<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p><object type="image/jpeg" data="no existo" width="25%">
<p class="italic">Tu navegador no puede mostrar esta imagen de <a href="http://es.wikipedia.org/wiki/Cristina Scabbia" title="Cristina Scabbia en Wikipedia">Cristina Scabbia, Lacuna Coil</a>cantando con su característico gesto apasionado, bajo la tenue iluminación azul del escenario.</p>
<p></object><br />
Tampoco quiero confundir a nadie, el cierre de la etiqueta de imagen solo significa que esa etiqueta no tiene contenido, pero se puede especificar con contenido:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="xml" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;no existo&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;25%&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;italic&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Tu navegador no puede mostrar esta imagen de <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> </span>
<span style="color: #009900;">		<span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;http://es.wikipedia.org/wiki/Cristina Scabbia&quot;</span> </span>
<span style="color: #009900;">		<span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Cristina Scabbia en Wikipedia&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Cristina Scabbia, Lacuna Coil<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		cantando con su característico gesto apasionado, bajo la tenue iluminación azul del escenario.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/img<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>No obstante sigue siendo muy pobre en comparación con object, no es estándar y por lo tanto si se renderiza bien solo es fruto de una funcionalidad específica del navegador en uso, por lo tanto es jugar con fuego. De hecho, una etiqueta de cierre de img está prohibida.<br />
Más referencias: <a href="http://html.conclase.net/w3c/html401-es/struct/objects.html#h-13.1">W3C &#8211; HTML4</a></p>
<h5>Salvando las dificultades</h5>
<h6>Sin Javascript y con reglas CSS</h6>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="xml" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;object</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg&quot;</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;image/jpeg&quot;</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;headerImg&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/object<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Cristina Scabbia de Lacuna Coil.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Yo prefiero con XML cerrar una etiqueta vacía: <del datetime="2009-10-08T13:41:00+00:00"><tt>class="testImgHead"&gt;&lt;/object&gt;</tt></del> <tt>class="testImgHead"/&gt;</tt></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;">[...].static.flickr.com/41/115559256_918ab03490_o_d.jpg&quot;/&gt;</pre></div></div>

<p><object data="http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg" type="image/jpeg" class="headerImg" height="200px" width="100%"></object>
<p>Cristina Scabbia de Lacuna Coil.</p>
<p>Para solucionar la expansión máxima de la imagen, bastaría con añadir una clase CSS que la redujera en el caso de estar desactivado Javascript. Ej:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;"><span style="color: #6666ff;">.adjustHeaderImageNoJs</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">200px</span> !important<span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #808080; font-style: italic;">/* Puede bastar con !important (cuidado IE6) pero dependería del CSS 
y siempre se puede aplicar más especificidad con herencia */</span>
html body <span style="color: #6666ff;">.post</span> <span style="color: #6666ff;">.entry</span> <span style="color: #6666ff;">.etc</span>... div<span style="color: #6666ff;">.headerImage</span><span style="color: #6666ff;">.adjustHeaderImageNoJs</span> object <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">200px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p><strong>¿Cómo?</strong> «<em>Captain Obvious to the rescue</em>» que dirían los <em>yankis</em> ^.^ , muy fácil -relativamente, claro-, eliminando dicha clase mediante Javascript <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> &#8230; o/y viceversa.<br />
Por ejemplo y a bote pronto -ojo-:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="javascript" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;"><span style="color: #006600; font-style: italic;">// Entendiendo que tenemos esta y el resto de funciones básicas</span>
<span style="color: #006600; font-style: italic;">// ...porque es un coñazo, ponerme a escribir ahora aquí el bucle para encontrar la clase.</span>
<span style="color: #003366; font-weight: bold;">var</span> newClasses	<span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Esto será string, no array.</span>
<span style="color: #003366; font-weight: bold;">var</span> objectClasses	<span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> myObjects		<span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByClassName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'headerImg'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// DOM 2 en todo caso</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">;</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;=</span> myObjects.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> myObject		<span style="color: #339933;">=</span> myObjects<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> objectAttrClass	<span style="color: #339933;">=</span> myObject.<span style="color: #660066;">getAttributeNS</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'class'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> objectClasses	<span style="color: #339933;">=</span> objectAttrClass.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">' '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">// Eliminar todas las clases:</span>
	myObject.<span style="color: #660066;">removeAttributeNS</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'class'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">// Volver a añadirlas excepto la que no queremos:</span>
	<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">;</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;=</span> objectClasses.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'adjustHeaderImageNoJs'</span> <span style="color: #339933;">!=</span> objectClasses<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// La clase que ajusta el objeto sin Js</span>
			newClasses <span style="color: #339933;">+=</span> objectClasses<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' '</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #006600; font-style: italic;">// Volver a añadir el atributo de clase</span>
	myObject.<span style="color: #660066;">setAttributeNS</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'class'</span><span style="color: #339933;">,</span> newClasses<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #006600; font-style: italic;">// Resto de instrucciones de proceso del objeto.</span></pre></td></tr></table></div>

<p>..mmm, como siempre, con jQuery sería tan sencillo como esto:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;">jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.headerImg'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'adjustHeaderImageNoJs'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h6>Sin Javascript ni CSS</h6>
<div><object data="http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg" type="image/jpeg" class="headerImg" width="200px" height="200px"></object>
<p>Cristina Scabbia de Lacuna Coil.</p>
</div>
<p>Tendríamos un problema ya algo serio ya que la imagen se expandiría sin remedio, esta vez sí, sin alternativa a usar una etiqueta de imagen&#8230; que no obstante, tendría el mismo problema:</p>
<div><img src="http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg" class="headerImg" width="200px" height="200px"></object>
<p>Cristina Scabbia de Lacuna Coil.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.culturadigital.org/tecnologia/desarrollo-web/xhtml-object-en-lugar-de-img/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JQuery&amp;object, imágenes de cabecera semánticas y limpias para XHTML</title>
		<link>http://blog.culturadigital.org/tecnologia/desarrollo-web/jquery-imagenes-de-cabecera-semanticas-y-limpias-para-xhtml</link>
		<comments>http://blog.culturadigital.org/tecnologia/desarrollo-web/jquery-imagenes-de-cabecera-semanticas-y-limpias-para-xhtml#comments</comments>
		<pubDate>Mon, 05 Oct 2009 23:10:21 +0000</pubDate>
		<dc:creator>J.A.Cobo</dc:creator>
				<category><![CDATA[Desarrollo web]]></category>
		<category><![CDATA[Diseño web]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[cabecera]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Imagen]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://blog.culturadigital.org/?p=562</guid>
		<description><![CDATA[Esta entrada tiene el objetivo de mostrar, una vez más, lo fácil que jQuery hace nuestro trabajo en desarrollo web, su flexibilidad y, lo más importante, como seguir manteniendo tu código limpio, semántico, estándar y flexible.
En este caso en concreto a través del uso de esa demasiado poco usada etiqueta &#60;object&#62; que, dicho sea de [...]]]></description>
			<content:encoded><![CDATA[<p>Esta entrada tiene el objetivo de mostrar, una vez más, lo fácil que jQuery hace nuestro trabajo en desarrollo web, su flexibilidad y, lo más importante, como seguir manteniendo tu código limpio, semántico, estándar y flexible.<br />
En este caso en concreto a través del uso de esa demasiado poco usada etiqueta <tt>&lt;object&gt;</tt> que, dicho sea de paso, sustituirá en un futuro (XHTML 2.0) y como debió ser desde el principio, a la etiqueta propietaria de Netscape <tt>&lt;img&gt;</tt>.<br />
Se puede ver el resultado de lo que se pretende <a href="http://blog.culturadigital.org/musica/cristina-scabbia-lacuna-coil" title="ver ejemplo en entrada de Cristina Scabbia">aquí</a> y <a href="http://laguardiadejaen.com/web/la-guardia/patrimonio-historico-y-cultural/monumentos-de-interes/antiguo-convento-de-santo-domingo/" title="Ver ejemplo en laguardiadejaen.com">aquí</a>.</p>
<p>Como siempre, ahí va un poco de contexto:</p>
<h4>Contexto</h4>
<p>En el sitio web donde trabajo -y en este blog-, hasta hace pocos días, usaba el siguiente código para maquetar una <strong>imagen bonita de cabecera</strong> para algunas entradas o secciones.</p>
<h5>Marcado no estructural</h5>
<p>Por ejemplo:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="xml" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;headerImg&quot;</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;height:200px; background:#333 url(http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg) no-repeat 0 30%;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Cristina Scabbia de Lacuna Coil.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>La cuestión era usar una imagen ya existente a tamaño original, ponerla como fondo para esa cabecera y añadir texto descriptivo a modo de visor en lugar de texto debajo de la imagen:<br />
<div id="attachment_590" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.culturadigital.org/media/2009/10/ImagenBonitaCabecera.png" rel="group_gallery"><img src="http://blog.culturadigital.org/media/2009/10/ImagenBonitaCabecera-300x177.png" alt="Ejemplo de imagen bonita de cabecera" title="ImagenBonitaCabecera" width="300" height="177" class="size-medium wp-image-590" /></a><p class="wp-caption-text">Ejemplo de imagen bonita de cabecera</p></div><br />
Nunca me gustó porque usaba estilo incrustado -aunque es posible hacerlo con CSS pero demasiado experimental- lo cual una vez más es marcado extra innecesario y no semántico: ya se sabe, <del datetime="2009-10-05T23:50:09+00:00" title="en este caso no importa">aumenta el peso de la página</del>, mezcla estilo y maquetación, etc. Empezó por ser algo provisional hasta que acabé por usarlo demasiado. Hace poco por fin me decidí a meterle mano aprovechando la flexibilidad y el desuso de la etiqueta <tt>object</tt>, y la potencia de jQuery.</p>
<h4>Solución</h4>
<p><strong>Usar una etiqueta <tt>object</tt> para la imagen</strong>, lo cual además de ser estándar actualmente, se adelanta a XHTML 2.0 y ya estás maquetando con soporte para un futuro muy lejano; todo esto sin olvidar que si estructuras en XHTML, es XML y las migraciones o la portabilidad se mantienen.</p>
<h5>¿Por qué object?</h5>
<p>Bien, usar un objeto va a dar muchísimo juego y las opciones pueden ser muchas. En este caso, no necesito inventar atributos ni etiquetas, que se podría hacer pero mantendremos un marcado estándar. Es decir:<br />
Puedes seguir usando una etiqueta de imagen pero para aplicar dimensiones y posiciones deberías usar o <em>peripecias</em> o marcado no válido como atributos raros que luego tendrías que eliminar con JS. En este caso deberías inventar algo para posicionar el fondo. ¿El atributo rel?, no, rel por mucho que nos pueda servir y sea estándar no es para eso&#8230; pero ¿por qué seguir pensando?:<br />
OBJECT: Se creó para esto justamente, admite más atributos que son completamente coherentes. Admite contenido alternativo. Admite parámetros de configuración que se abstraen precisamente del marcado que es lo que realmente queremos.</p>
<h5>¿Por qué Javascript?</h5>
<p>Aunque la tercera cuestión es la más importante, con Javascript, y jQuery en concreto, fabricas una funcionalidad más sólida que, como ya he dicho antes, con CSS avanzado y parcialmente soportado, aunque igualmente la base de todo sea XPath (<em>aludimos a los selectores avanzados de CSS</em>).</p>
<h5>¿Por qué XML?</h5>
<p>Lo bueno de XML y que tu maquetación básica sea estándar, es, por ejemplo, el uso de Javascript:<br />
Mañana, si quiero eliminar el Javascript puedo hacerlo perfectamente y la funcionalidad de la imagen -el marcado XHTML estándar y semántico- va a seguir prácticamente igual. En este ejemplo se desproporciona la imagen pero es corregible mediante CSS si se desea.<br />
Otra opción, al ser XML, es que puedes aplicarle por ejemplo XSLT si lo prefieres.</p>
<p>En definitiva, hay muchísimas opciones desarrollando en XML, desde que conocí el lenguaje no he hecho otra cosa más que ver sus ventajas <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<h5>Marcado estándar, coherente y semántico</h5>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="xml" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;headerImg&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;object</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg&quot;</span> </span>
<span style="color: #009900;">		<span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;200px&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;background-position&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;0% 30%&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/object<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Cristina Scabbia de Lacuna Coil.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Con Mime type:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="xml" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;">[...]<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;object</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;image/jpeg&quot;</span> <span style="color: #66cc66;">&#91;</span>...<span style="color: #66cc66;">&#93;</span></span></pre></td></tr></table></div>

<p>Todo es válido, estándar, semántico y sencillo.<br />
Para object puedes establecer incluso el mimetype, puedes establecer como contenido alternativo tu imagen y gestionarla de nuevo con lo que prefieras. Bastaría con meter dentro de la etiqueta del objeto el contenido alternativo, en este caso nuestra imagen que queremos mostrar, e igualmente aplicarle cambios, o dinámicos, o mediante estilos, o volviendo a los inicios, con estilos incrustados:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="xml" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;headerImg&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;object</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg&quot;</span> </span>
<span style="color: #009900;">		<span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;200px&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;background-position&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;0% 30%&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> </span>
<span style="color: #009900;">			<span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;http://farm1.static.flickr.com/41/115559256_918ab03490_o_d.jpg&quot;</span> </span>
<span style="color: #009900;">			<span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;Texto alternativo&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;estilos CSS&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/object<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Cristina Scabbia de Lacuna Coil.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Y&#8230; vuelta a empezar por ejemplo con modificaciones JavaScript si queremos.</p>
<p>Es decir, este es el proceso por descarte:<br />
XHTML válido + Javascript <tt>-si falla Javascript-></tt><br />
XHTML válido y usable <tt>-si falla XHTML (object)-></tt><br />
marcado usable tradicional que, aun pudiendo no ser válido, igualmente era la primera opción.</p>
<h5>Proceso con jquery</h5>
<p>Pues como siempre que usamos esta fantástica librería, muy sencillo: Un poco de XPath y ya está.</p>
<h6>Código Javascript</h6>
<p>Bueno&#8230; un poco, pero obviamente se puede y debe mejorar con lo cual te extiendes un poco más y te puede salir algo así:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
</pre></td><td class="code"><pre class="javascript" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;"><span style="color: #003366; font-weight: bold;">function</span> imageHeaderPosts<span style="color: #009900;">&#40;</span>elm<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> jQuery<span style="color: #009900;">&#40;</span>elm<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// INIT:</span>
		<span style="color: #003366; font-weight: bold;">var</span> errorMsg	<span style="color: #339933;">=</span> <span style="color: #3366CC;">'No se puede crear un visor de imagen para '</span> <span style="color: #339933;">+</span> elm <span style="color: #339933;">+</span> <span style="color: #3366CC;">'.'</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> parentElm	<span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span>elm<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> objectElm	<span style="color: #339933;">=</span> parentElm.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'object'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #339933;">!==</span> objectElm.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#41;</span>
			<span style="color: #000066; font-weight: bold;">throw</span> <span style="color: #003366; font-weight: bold;">new</span> Error<span style="color: #009900;">&#40;</span>errorMsg <span style="color: #339933;">+</span> <span style="color: #3366CC;">' No contiene un objeto a procesar.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> bckgImg<span style="color: #339933;">,</span> imgHeight<span style="color: #339933;">,</span> bckgColor<span style="color: #339933;">,</span> bckgPos<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// Atributos por defecto:</span>
		<span style="color: #003366; font-weight: bold;">var</span> defImgHeight<span style="color: #339933;">=</span> <span style="color: #3366CC;">'200px'</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> defBckgImg<span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> defBckgColor<span style="color: #339933;">=</span> <span style="color: #3366CC;">'#333'</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> defBckgPos	<span style="color: #339933;">=</span> <span style="color: #3366CC;">'0% 20%'</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// VISOR:</span>
		imgHeight 	<span style="color: #339933;">=</span> objectElm.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'height'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		bckgImg 		<span style="color: #339933;">=</span> objectElm.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'data'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		bckgColor 	<span style="color: #339933;">=</span> objectElm.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'param[name=background-color]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'value'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		bckgPos 		<span style="color: #339933;">=</span> objectElm.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'param[name=background-position]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'value'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// Check:</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'undefined'</span> <span style="color: #339933;">===</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>imgHeight<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> 
			imgHeight	<span style="color: #339933;">=</span> defImgHeight<span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'undefined'</span> <span style="color: #339933;">===</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>bckgImg<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> 
			bckgImg		<span style="color: #339933;">=</span> defBckgImg<span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'undefined'</span> <span style="color: #339933;">===</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>bckgColor<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> 
			bckgColor	<span style="color: #339933;">=</span> defBckgColor<span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'undefined'</span> <span style="color: #339933;">===</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>bckgPos<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> 
			bckgPos		<span style="color: #339933;">=</span> defBckgPos<span style="color: #339933;">;</span>
		<span style="color: #006600; font-style: italic;">// Run...</span>
		parentElm.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #3366CC;">'height'</span><span style="color: #339933;">:</span>				imgHeight<span style="color: #339933;">,</span> 
			<span style="color: #3366CC;">'background-color'</span><span style="color: #339933;">:</span>		bckgColor<span style="color: #339933;">,</span> 
			<span style="color: #3366CC;">'background-image'</span><span style="color: #339933;">:</span>	<span style="color: #3366CC;">'url('</span> <span style="color: #339933;">+</span> bckgImg <span style="color: #339933;">+</span> <span style="color: #3366CC;">')'</span><span style="color: #339933;">,</span> 
			<span style="color: #3366CC;">'background-position'</span><span style="color: #339933;">:</span>	bckgPos<span style="color: #339933;">,</span> 
			<span style="color: #3366CC;">'background-repeat'</span><span style="color: #339933;">:</span>	<span style="color: #3366CC;">'no-repeat'</span><span style="color: #339933;">,</span> 
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		objectElm.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #006600; font-style: italic;">// Lanzar:</span>
imageHeaderPosts<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.headerImg'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Como hemos dicho antes, lo único que hacemos es aprovechar los parámetros de configuración del objeto. Nosotros les aplicamos JavaScript, pero están ahí para cualquier otro lenguaje o proceso. La cuestión es mantener el marcado coherente, limpio y sin fabricar <em>cosas raras</em> <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Sobre el comportamiento en sí es necesario aclarar: Usamos una división contenedor tanto para buscarla como para aplicarle cambios: <tt>&lt;div class="headerImg"&gt;</tt> pero también podríamos actuar directamente sobre el elemento <tt>object</tt> con unas cuantas modificaciones más.</p>
<h4>Resultado</h4>
<div class="wp-caption alignleft"><a href="http://blog.culturadigital.org/media/2009/10/ImagenBonitaCabecera.png" title="Cabecera bonita usando XHTML (object) y modificaciones Javascript" rel="group_gallery"><img src="http://blog.culturadigital.org/media/2009/10/ImagenBonitaCabecera-300x177.png" alt="Ejemplo de imagen bonita de cabecera" title="ImagenBonitaCabecera" width="300" height="177" class="size-medium wp-image-590" /></a>
<p class="wp-caption-text">Cabecera bonita usando XHTML (object) y Javascript</p>
</div>
<div class="wp-caption alignleft"><a href="http://blog.culturadigital.org/media/2009/10/EjemploObjectsinJavascript.png" title="Cabecera bonita usando XHTML (object) SIN Javascript" rel="group_gallery"><img src="http://blog.culturadigital.org/media/2009/10/EjemploObjectsinJavascript-300x166.png" alt="Cabecera bonita usando object sin Javascript" title="EjemploObjectsinJavascript" width="300" height="166" class="size-medium wp-image-632" /></a>
<p class="wp-caption-text">Cabecera bonita usando XHTML (object) SIN Javascript</p>
</div>
<p><br class="clear" /></p>
<div class="wp-caption alignleft"><a href="http://blog.culturadigital.org/media/2009/10/CabeceraBonitaJavascript.png" title="Cabecera bonita con object y Javascript" rel="group_gallery"><img src="http://blog.culturadigital.org/media/2009/10/CabeceraBonitaJavascript-300x115.png" alt="Cabecera bonita con object y Javascript" title="CabeceraBonitaJavascript" width="300" height="115" class="size-medium" /></a>
<p class="wp-caption-text">Cabecera bonita con object y Javascript</p>
</div>
<div class="wp-caption alignleft"><a href="http://blog.culturadigital.org/media/2009/10/CabeceraBonitaSinJavascript.png" title="Cabecera bonita con object SIN Javascript" rel="group_gallery"><img src="http://blog.culturadigital.org/media/2009/10/CabeceraBonitaSinJavascript-300x116.png" alt="Cabecera bonita con object y Javascript" title="CabeceraBonitaJavascript" width="300" height="115" class="size-medium" /></a>
<p class="wp-caption-text">Cabecera bonita con object SIN Javascript</p>
</div>
<h4 class="clear">Otras consideraciones</h4>
<p>Algunas otras aplicaciones y/o alternativas y en las que he pensado mientras escribía esto han sido: usar tu propio Namespace -más válido-; si usas Wordpress, tu filtro para etiquetas propias; o simplemente CSS experimental:</p>
<dl>
<dt>Wordpress</dt>
<dd>Si usas Wordpress, quizá una solución más heterodoxa sea aplicar filtros propios para generar etiquetas.<br />
Este es un ejemplo sencillo del uso de filtros para aplicar al contenido:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;"><span style="color: #000000; font-weight: bold;">function</span> myFilterTest<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$content</span>	<span style="color: #339933;">=</span> <span style="color: #990000;">str_ireplace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;test&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;strong&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$content</span>	<span style="color: #339933;">=</span> <span style="color: #990000;">str_ireplace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;/test&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/strong&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// Más técnico y costoso:</span>
	<span style="color: #666666; font-style: italic;">//$content	= preg_replace('#\&lt;test\&gt;(.*?)\&lt;/test\&gt;#si', '&lt;strong&gt;\1&lt;/strong&gt;', $content);</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'myFilterTest'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Para aplicarlo a este ejemplo ya depende de tu imaginación.</dd>
<dt>Namespace propio</dt>
<dd>Etiquetas propias con un «Namespace» propio también puede parecer demasiado extremo <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_mrgreen.gif' alt=':mrgreen:' class='wp-smiley' /><br />
No obstante, lo mismo lo pruebo &#8230;porque de lo que se trata es de experimentar <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </dd>
<dt>CSS</dt>
<dd>Por último y como dije al principio, también es posible mediante CSS pero si pensamos, por ejemplo, en la posibilidad de que Javascript esté deshabilitado&#8230; es mucho más probable que el navegador no soporte los selectores avanzados de CSS entre otras características.</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://blog.culturadigital.org/tecnologia/desarrollo-web/jquery-imagenes-de-cabecera-semanticas-y-limpias-para-xhtml/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery: Solución al max-&amp;min CSS en IE</title>
		<link>http://blog.culturadigital.org/tecnologia/desarrollo-web/jquery-solucion-al-max-min-css-en-ie</link>
		<comments>http://blog.culturadigital.org/tecnologia/desarrollo-web/jquery-solucion-al-max-min-css-en-ie#comments</comments>
		<pubDate>Sun, 06 Sep 2009 18:13:47 +0000</pubDate>
		<dc:creator>J.A.Cobo</dc:creator>
				<category><![CDATA[Desarrollo web]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[dimensions]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[internet-explorer]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[max-width]]></category>
		<category><![CDATA[min-width]]></category>

		<guid isPermaLink="false">http://blog.culturadigital.org/?p=379</guid>
		<description><![CDATA[Si es que jQuery es una maravilla  
Información:Esta entrada es antigua, se ha reabierto -y actualizado un poco- pero data de al menos casi dos años, de ahí referencias obsoletas a temas como «dimensions», el cual se incluye hace tiempo ya como base de «jQuery».
Un poco de Off Topic:
Si hay algún lector habitual de [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Si es que jQuery es una maravilla</strong> <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p class="info"><strong>Información</strong>:<br />Esta entrada es antigua, se ha reabierto -<em>y actualizado un poco</em>- pero data de al menos casi dos años, de ahí referencias obsoletas a temas como «<em>dimensions</em>», el cual se incluye hace tiempo ya como base de «jQuery».</p>
<p>Un poco de Off Topic:</p>
<blockquote><p>Si hay algún lector habitual de Cultura Digital ya conocerá mi habitual tendencia a irme por las ramas o establecer contextos sobre el tema central de la entrada&#8230; Qué le voy a hacer, después de todo, esto es un blog -un blog nacido con pretensiones artísticas- no un compendio de artículos técnico-temáticos; así que siempre me voy a permitir la libertad de divagar -y puede que incluso utilizando recursos literarios- un poco o un mucho, según me de <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p></blockquote>
<p>Pero en fin, por ahora, vamos con ello:</p>
<h4>Contexto</h4>
<p>Aunque llevaba tiempo resignado aún habiendo soluciones, tampoco era un problema demasiado severo siempre que diseñaras en «fixed». Recordé que Cameron Moll, en el famoso «CSS Mastering» de Andy Budd -la traducción de Anaya&reg; no es gran cosa- indicaba una expresión propietaria de <acronym title="(Microsoft) Internet Explorer">IE</acronym> con JavaScript para «solucionar» el problema.</p>
<h5>Soluciones habituales</h5>
<p>En el portátil dónde suelo probar el diseño en IE (Windows XP SP2 + IE6 de casa) no me ha funcionado, está a 1024, y ninguna de las otras soluciones que he encontrado, como la del «crack» Dean Edwards, tampoco han servido de mucho. Entre ellas algunos resets de prestigio como el de Yahoo, del mismo Dean Edwards&#8230;<br />
<ins datetime="2009-09-06T18:20:19+00:00">
<p class="info"><strong>Información</strong><br />Actualizado: Hoy por hoy -09/09-, el mismo Edwards ha desarrollado soluciones de compatibilidad con estándares, y en este caso en concreto con CSS, dónde evidentemente ya podemos usar min-width, max-width y muchos otros, no sé cuantos, pseudo-selectores en casi o todas las versiones IE, al menos 6, 7 y 8.<br />
Enlace: <a href="http://dean.edwards.name/weblog/2008/01/ie7-2/" title="Enlace a la entrada en el blog de Dean">Dean Edwards IE7 Actualizaciones</a></p>
<p></ins></p>
<h5>Test</h5>
<p>El caso es que el resultado de <tt>laguardiadejaen.com</tt> para IE, con unos pocos arreglos sobre imágenes y un CSS con unas 6/7 reglas para solucionar problemas específicos, no difiere mucho del diseño basado en estándares o por ejemplo del resultado en FF (Firefox). Pero&#8230; tenía un inconveniente bastante desagradable que me alarmó al ver los accesos por resoluciones de pantalla:</p>
<h5>Resoluciones de usuario</h5>
<p>El último cambio de <em>look</em> se basaba en esto, una ampliación de la anchura gracias a la creciente facilidad para adquirir pantallas planas o monitores -¿monitores?&#8230; me atrevería a decir que prácticamente se han extinguido en el ámbito doméstico-, pues eso: resolví que 1260 podría ser en poco tiempo la media&#8230; de hecho, casi lo es ya, pero por ahora continuamos en 1024.<br />
Así que cambié a un diseño fluido de 1000 píxeles mínimos, algo justo pero válido para resoluciones de 1024, y 1260 de máxima anchura para resoluciones más grandes y que no diera un ancho excesivo.</p>
<p>Bien&#8230; pues encontré que había bastantes accesos a 800&#8230;, ¡Dios! -aún no había tanto acceso con pda&#8217;s, móviles, etc-. A 800 y con I. Explorer, sin poder usar <tt>min-width</tt>, ufff&#8230; aunque no hice nada en ese momento -había cosas más serias-, al final era inevitable usar una solución en un trabajo para un organismo público:</p>
<h4>La solución: de nuevo jQuery</h4>
<p><strong>Dimensions</strong>:<br />
En una entrada anterior hablaba de como me sorprendió este plugin para jQuery&#8230; Así que después de probar mil y un <em>hacks</em> que, como decía, no me convencieron y sobre todo, no funcionaban (por ejemplo para usar un reset debes usarlo desde el principio&#8230; y el que estés usando seguir usándolo), decidí probar con JavaScript, jQuery y su plugin Dimensions:</p>
<h5>Código JS</h5>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="javascript" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> charset<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;utf-8&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #006600; font-style: italic;">// &lt;![CDATA[</span>
jQuery<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> jQuery.<span style="color: #660066;">browser</span>.<span style="color: #660066;">msie</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		jQuery<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">resize</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> windowWidth 	<span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> wrapper 		<span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#wrapper'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'number'</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>windowWidth<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #3366CC;">'object'</span> <span style="color: #339933;">===</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>wrapper<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">if</span> 		<span style="color: #009900;">&#40;</span> windowWidth <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">1000</span> <span style="color: #009900;">&#41;</span>	wrapper.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> 	<span style="color: #009900;">&#40;</span> windowWidth <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">1260</span> <span style="color: #009900;">&#41;</span>	wrapper.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1260</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">else</span>							wrapper.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'98%'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// ]]&gt;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Y para hacer un test dejo esto:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="javascript" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> charset<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;utf-8&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #006600; font-style: italic;">// &lt;![CDATA[</span>
jQuery<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">// IE, simular max y min-width con dimensions:</span>
	jQuery<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">resize</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> windowWidth	<span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> wrapper		<span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#wrapper'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> wrapperWidth	<span style="color: #339933;">=</span> wrapper.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> msgWindow	<span style="color: #339933;">=</span> <span style="color: #3366CC;">'Resolución: '</span> <span style="color: #339933;">+</span> windowWidth<span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> msgWrapper	<span style="color: #339933;">=</span> <span style="color: #3366CC;">'Wrapper ajustado a: '</span> <span style="color: #339933;">+</span> wrapperWidth<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> windowWidth <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">1000</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			wrapper.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>msgWindow <span style="color: #339933;">+</span> <span style="color: #3366CC;">' min-width activo!.'</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span> <span style="color: #339933;">+</span> msgWrapper<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> windowWidth <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">1260</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			wrapper.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1260</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>msgWindow <span style="color: #339933;">+</span> <span style="color: #3366CC;">' max-width activo!.'</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span> <span style="color: #339933;">+</span> msgWrapper<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			wrapper.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'98%'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>msgWindow <span style="color: #339933;">+</span> <span style="color: #3366CC;">' dentro de los límites.'</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span> <span style="color: #339933;">+</span> msgWrapper<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// ]]&gt;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Obviamente, en un navegador estándar, restrinjo el ancho con la división <tt>wrapper</tt> que envuelve la maquetación, un 98% me parece bien para aplicar un pequeño margen en resoluciones inferiores a 1260 y en concreto a 1024 trabajando a 1000 píxeles más o menos.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.culturadigital.org/tecnologia/desarrollo-web/jquery-solucion-al-max-min-css-en-ie/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Breve tutorial Facebook Connect rápido de verdad</title>
		<link>http://blog.culturadigital.org/tecnologia/desarrollo-web/breve-tutorial-facebook-connect-rapido-de-verdad</link>
		<comments>http://blog.culturadigital.org/tecnologia/desarrollo-web/breve-tutorial-facebook-connect-rapido-de-verdad#comments</comments>
		<pubDate>Mon, 17 Aug 2009 07:57:25 +0000</pubDate>
		<dc:creator>J.A.Cobo</dc:creator>
				<category><![CDATA[Desarrollo web]]></category>
		<category><![CDATA[Diseño web]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Connect]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[mashups]]></category>

		<guid isPermaLink="false">http://blog.culturadigital.org/?p=507</guid>
		<description><![CDATA[Antes de nada comentaré que es una de las pocas modas en la web, y en concreto en la blogosfera, que me parece bastante útil y que me gusta bastante -si usas «Facebook» claro, &#8230;y si no: acabarás usándolo xP-. Sé que ya antes existía «OpenId» y tal y que caminamos, de forma irremediable, a [...]]]></description>
			<content:encoded><![CDATA[<p>Antes de nada comentaré que es una de las pocas modas en la web, y en concreto en la <em>blogosfera</em>, que me parece bastante útil y que me gusta bastante -si usas «Facebook» claro, &#8230;y si no: acabarás usándolo xP-. Sé que ya antes existía «OpenId» y tal y que caminamos, de forma irremediable, a la globalización totalmente ya total <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  en la que, ya de verdad, tendremos una identidad única y global en la red -la unión de servicios como FB Connect, Google FC, OpenId&#8230; creo que no debe tardar-; espero que siempre y cuando así lo deseemos.</p>
<p>Además, piensa que, en el caso de los comentarios de un blog por ejemplo, se ahorran implementaciones extra y recursos como chequeos de usuarios -aunque siga habiendo spam en Facebook- ya que, en general, se usa una gestión externa con los beneficios que ello conlleva, aunque también, obviamente, sus desventajas.</p>
<p class="alert"><ins datetime="2010-01-16T09:51:20+00:00" title="Añadido 16/01/2010" class="nodecoration">(16/01/2010) <strong>Muy importante</strong>: No estoy seguro porque no he hecho todas las pruebas necesarias, pero al menos a mí, en dos servidores y aplicaciones distintas:<br />El script (js) de la librería de Facebook <strong class="red">me da error sirviendo como: <tt>application/xhtml+xml</tt></strong>, es decir XML de verdad.<br />En el blog funciona porque se sirve como html plano, al menos el documento real, las cabeceras; el marcado, DocType y tal es otro tema aunque debería ser el mismo.<br />Es decir: <strong class="blue">Funciona sirviendo como <tt>text/html</tt></strong></ins></p>
<h4>Tutorial rápido</h4>
<p>Bien, en cualquier caso, paso ya a escribir esta especie de minitutorial rápido para aquellos que, pese a darle tanto bombo, resulta que el vídeo de 8 minutos -como ya ha comentado alguien por ahí- no son tan 8 minutos y sí más bien unos cuantos más, sin contar porrazos al teclado estilo «niño alemán de Youtube», etc.</p>
<p>Como siempre recordar que solo pretendo echar una mano a aquellos que, quizá como yo, se hayan atrancado intentando implementar el servicio por su cuenta o a través de plugins. Personalmente soy bastante poco amigo de los plugins -en Wordpress me refiero-&#8230; esto ya es otra historia. aunque reconozco su valía para usuarios web finales que, a decir verdad, hoy no son lo que era antes: Es decir, no hay porqué ser un diseñador o desarrollador web para tener un blog, la verdad.<br />
Así que vamos allá:</p>
<h4>Empecemos</h4>
<p>Al menos, esta es la forma como yo lo he hecho, liberando al sitio web de librerías propias -aunque estoy deseando probarlo al completo en PHP- y creando un sistema más o menos rápido y sencillo mediante la api y librerías de Facebook. Vamos, lo normal.</p>
<h5>1. Creando la conexión Facebook App &#8211; tu blog</h5>
<p>Esto básicamente lo podéis mirar aquí:<br />
<a href="http://wiki.developers.facebook.com/index.php/Facebook_Connect_Tutorial1">Facebook Connect &#8211; Tutorial 1</a>.</p>
<p>Como en el resto de tutoriales que se hayan podido consultar, lo primero es crear tu aplicación en Facebook.<br />
&#8230;hay muchos tutoriales sobre cómo hacer pero lo básico, al margen de estar registrado en Facebook y en la sección de desarrolladores ^^!, sería comentar que hay muuuuuuchos manuales que nos hablan sobre la antigua interfaz de configuración, que ha cambiado, que si canvas url, callback post y delete&#8230; Nos os liéis!!:</p>
<ul>
<li><strong>Nombre de la aplicación</strong></li>
<li><strong>Url Callback</strong> -donde irá vuestro famoso xd_receiver.html-</li>
<li>y, esto no estoy seguro, activar el uso del marcado especial de Facebook -necesitará un namespace extra en el<br />
	documento- <strong>FBML</strong> en lugar de un marco: <strong>iframe</strong>.</li>
</ul>
<p>¡PUNTO!</p>
<h6>En imágenes</h6>

<a href='http://blog.culturadigital.org/tecnologia/desarrollo-web/breve-tutorial-facebook-connect-rapido-de-verdad/attachment/fbconnectcreateapp' title='FBConnectCreateApp'><img width="150" height="150" src="http://blog.culturadigital.org/media/2009/08/FBConnectCreateApp-150x150.png" class="attachment-thumbnail" alt="Facebook Connect: Crear aplicación" title="FBConnectCreateApp" /></a>
<a href='http://blog.culturadigital.org/tecnologia/desarrollo-web/breve-tutorial-facebook-connect-rapido-de-verdad/attachment/fbconnecteditnewapp' title='FBConnectEditNewApp'><img width="150" height="150" src="http://blog.culturadigital.org/media/2009/08/FBConnectEditNewApp-150x150.png" class="attachment-thumbnail" alt="Facebook Connect: Editar aplicación" title="FBConnectEditNewApp" /></a>
<a href='http://blog.culturadigital.org/tecnologia/desarrollo-web/breve-tutorial-facebook-connect-rapido-de-verdad/attachment/fbconnecteditnewapp2blur' title='FBConnectEditNewApp2Blur'><img width="150" height="150" src="http://blog.culturadigital.org/media/2009/08/FBConnectEditNewApp2Blur-150x150.png" class="attachment-thumbnail" alt="Facebook Connect: Editar aplicación, url connect xd_receiver" title="FBConnectEditNewApp2Blur" /></a>

<h5>2. Lo importante de verdad.</h5>
<p>Así es como yo lo he implementado -con JavaScript (parte de jQuery)- en el blog y, hasta ahora, funciona bien.</p>
<p class="alert"><strong>Importante</strong>: Todo el código a continuación, es más o menos a modo rápido de prueba. Por ejemplo, Facebook Connect se debería inicializar con el Bootstrap de la librería (ver wiki), para asegurarse de la carga completa de la misma, el DOM, etc.</p>
<dl>
<dt><strong>Incluye el <tt>Namespace</tt></strong> del marcado de Facebook (FBML):</dt>
<dd><tt>xmlns:fb="http://www.facebook.com/2008/fbml"</tt></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;">	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html</span> </span>
<span style="color: #009900;">		<span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span> </span>
<span style="color: #009900;">		<span style="color: #000066;">xmlns:fb</span>=<span style="color: #ff0000;">&quot;http://www.facebook.com/2008/fbml&quot;</span> </span>
<span style="color: #009900;">		<span style="color: #000066;">xml:lang</span>=<span style="color: #ff0000;">&quot;es&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span> <span style="color: #808080; font-style: italic;">&lt;!-- Yo, es que no uso el language_attributes() pero vamos... puedes hacerlo aquí --&gt;</span></pre></div></div>

<p>	Aunque es muy muy pesado, si lo prefieres, imagino que también puedes usar namespaces incrustados en lugar del<br />
	atributo del html; por ejemplo, si vas a generar poco código FBML y todo tú.<br />
	Ej.:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;">		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fb:login-button</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.facebook.com/2008/fbml&quot;</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">&quot;medium&quot;</span> <span style="color: #000066;">length</span>=<span style="color: #ff0000;">&quot;long&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>	Resultado: <fb:login-button xmlns="http://www.facebook.com/2008/fbml" size="medium" length="long" /></dd>
<dt>Incluye el script de Facebook</dt>
<dd>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> </span>
<span style="color: #009900;">		<span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/es_ES&quot;</span> </span>
<span style="color: #009900;">		<span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span> </span>
<span style="color: #009900;">		<span style="color: #000066;">charset</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

</dd>
<dt><strong>Archivo <tt>comments.php</tt></strong>:</dt>
<dd>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre></td><td class="code"><pre class="php" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;">	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$user_ID</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	...
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">else</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	...
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">// Facebook Connect ?&gt;</span>
	&lt;p id=&quot;facebookConnect&quot;&gt;
		&lt;span id=&quot;facebookLogin&quot;&gt;&lt;/span&gt;
		&lt;!-- ó &lt;span id=&quot;facebookLogin&quot; /&gt; --&gt;
		&lt;!-- ó incluso &lt;span id=&quot;facebookLogin&quot;/&gt; si sirves xml de verdad --&gt;
	&lt;/p&gt;
	...
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">// END Facebook Connect ?&gt;</span>
&nbsp;
	&lt;p id=&quot;userBox&quot;&gt;
		&lt;input 
			type=&quot;text&quot; name=&quot;author&quot; id=&quot;author&quot; 
			value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$comment_author</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; size=&quot;22&quot; tabindex=&quot;1&quot; /&gt; 
		&lt;label for=&quot;author&quot;&gt;
			&lt;span class=&quot;x-small<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$req</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">' required'</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
				<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$req</span> <span style="color: #009900;">&#41;</span> ? _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
			&lt;/span&gt;
		&lt;/label&gt;
	&lt;/p&gt;
&nbsp;
	&lt;p id=&quot;userMail&quot;&gt;
		&lt;input type=&quot;text&quot; name=&quot;email&quot; id=&quot;email&quot; 
			value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$comment_author_email</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; size=&quot;22&quot; tabindex=&quot;2&quot; /&gt; 
		&lt;label for=&quot;email&quot;&gt;
			&lt;span class=&quot;x-small<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$req</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">' required'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
				Email (no se publicar&amp;aacute;) <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$req</span> <span style="color: #009900;">&#41;</span> ? _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
			&lt;/span&gt;
		&lt;/label&gt;
	&lt;/p&gt;
&nbsp;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

</dd>
</dl>
<p><strong>Javascript</strong>: Preferiblemente incluir <strong>antes de la etiqueta body</strong> de tu documento. Por ejemplo puedes añadirlo al <tt>wp_footer()</tt>, tú mismo.</p>
<p>Unas <strong>cuántas cuestiones interesantes</strong>:<br />
En estos ejemplos hay ciertas cosas que lo mismo pueden liar a alguien pero son bastante triviales.</p>
<ul>
<li>Por ejemplo aplico mediante jQuery una clase CSS que añade el cursor correspondiente (pointer) &#8211; M$I.E. usa <tt>cursor: hand;</tt> -<br />
Si se prefiere usar CSS al vuelo con jQuery debería bastar con algo como:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;">jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'elemento'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cursor'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'pointer'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Pero yo prefiero crear marcado válido incluso si es con JavaScript al vuelo (<em>el método anterior añade estilo incrustado mientras que si usas una clase sigue siendo válido y no intrusivo</em>), además de que es una clase que ya uso normalmente.</li>
<li>También es necesario tener en cuenta los identificadores de los elementos párrafo que engloban las secciones, en este caso nombre y correo: <tt>userBox</tt> y <tt>userMail</tt>; además del <em>wrapper</em> HTML en el botón de login para aplicarle cambios sin tener que tocar el marcado de facebook FBML: <tt>facebookLogin</tt>.</li>
</ul>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
</pre></td><td class="code"><pre class="javascript" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> charset<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;utf-8&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #006600; font-style: italic;">// &lt;![CDATA[</span>
	jQuery<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> apiKey		<span style="color: #339933;">=</span> <span style="color: #3366CC;">'CLAVE_DE_TU_APLICACIÓN_ACCESO_A_LA_API'</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> channelPath	<span style="color: #339933;">=</span> <span style="color: #3366CC;">'URL A TU RECEIVER: xd_receiver.htm'</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009966; font-style: italic;">/* DESCONECTADO */</span>
		<span style="color: #003366; font-weight: bold;">function</span> fbNotConnected<span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#facebookLogin'</span><span style="color: #009900;">&#41;</span>
			.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'pointer'</span><span style="color: #009900;">&#41;</span>
			.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;fb:login-button size=&quot;medium&quot; length=&quot;long&quot; /&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			FB.<span style="color: #660066;">XFBML</span>.<span style="color: #660066;">Host</span>.<span style="color: #660066;">parseDomTree</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #009966; font-style: italic;">/* CONECTADO */</span>
		<span style="color: #003366; font-weight: bold;">function</span> fbConnected<span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> api			<span style="color: #339933;">=</span> FB.<span style="color: #660066;">Facebook</span>.<span style="color: #660066;">apiClient</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> userUid		<span style="color: #339933;">=</span> api.<span style="color: #660066;">get_session</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">uid</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #003366; font-weight: bold;">var</span> htmlLogin 	<span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;span&gt;&lt;fb:profile-pic uid=&quot;loggedinuser&quot; facebook-logo=&quot;true&quot; linked=&quot;false&quot; '</span>
			<span style="color: #339933;">+</span> <span style="color: #3366CC;">'class=&quot;alignleft&quot; /&gt; Bienvenido &lt;fb:name uid=&quot;loggedinuser&quot; useyou=&quot;false&quot; /&gt;'</span>
			<span style="color: #339933;">+</span> <span style="color: #3366CC;">', estás conectado con tu cuenta de Facebook.'</span>
			<span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;fb:user uid=&quot;loggedinuser&quot; /&gt;&lt;fb:website uid=&quot;loggediuserin&quot; /&gt;&lt;/span&gt;'</span><span style="color: #339933;">;</span>
			<span style="color: #006600; font-style: italic;">// Según mi punto de vista, no se debería usar php incrustado -the_permalink()-</span>
			<span style="color: #003366; font-weight: bold;">var</span> htmlLogout 	<span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;a class=&quot;pointer&quot; title=&quot;Desconectar de tu cuenta Facebook y esta web.&quot; '</span>
			<span style="color: #339933;">+</span> <span style="color: #3366CC;">'onclick=&quot;FB.Connect.logoutAndRedirect(<span style="color: #000099; font-weight: bold;">\'</span>&lt;?php the_permalink(); ?&gt;<span style="color: #000099; font-weight: bold;">\'</span>); return false;&quot;&gt;'</span>
			<span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;img alt=&quot;Logout&quot; src=&quot;http://static.ak.fbcdn.net/rsrc.php/zDUG0/hash/3g5yiwv5.gif&quot;&gt;&lt;/a&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
			api.<span style="color: #660066;">users_getInfo</span><span style="color: #009900;">&#40;</span>userUid<span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'name'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'website'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'profile_url'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>res<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				fbGenerateFormField<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'author'</span><span style="color: #339933;">,</span> res<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				fbGenerateFormField<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'email'</span><span style="color: #339933;">,</span> userUid <span style="color: #339933;">+</span> <span style="color: #3366CC;">'@facebook.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'string'</span> <span style="color: #339933;">===</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>res<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">website</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#commentform input#url'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'value'</span><span style="color: #339933;">,</span> res<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">website</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #006600; font-style: italic;">// Forzar: fbUpdateFormField('url', res[0].website);</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'string'</span> <span style="color: #339933;">===</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>res<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">profile_url</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>  
						jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#commentform input#url'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'value'</span><span style="color: #339933;">,</span> res<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">profile_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #006600; font-style: italic;">// Forzar: fbUpdateFormField('url', res[0].profile_url);</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#facebookLogin'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>htmlLogout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#userBox'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>htmlLogin<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#userMail'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			FB.<span style="color: #660066;">XFBML</span>.<span style="color: #660066;">Host</span>.<span style="color: #660066;">parseDomTree</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #003366; font-weight: bold;">function</span> fbGenerateFormField<span style="color: #009900;">&#40;</span>elId<span style="color: #339933;">,</span> value<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> formField <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;input id=&quot;'</span> <span style="color: #339933;">+</span> elId <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot; name=&quot;'</span> <span style="color: #339933;">+</span> elId <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot; value=&quot;'</span> <span style="color: #339933;">+</span> value <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot; type=&quot;hidden&quot; /&gt;'</span><span style="color: #339933;">;</span>
			jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'form#commentform'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>formField<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// Init setup:</span>
		FB.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span>apiKey<span style="color: #339933;">,</span> channelPath<span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;ifUserConnected&quot;</span> <span style="color: #339933;">:</span> fbConnected<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;ifUserNotConnected&quot;</span> <span style="color: #339933;">:</span> fbNotConnected <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #006600; font-style: italic;">// End jQuery</span>
<span style="color: #006600; font-style: italic;">// ]]&gt;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<h4>Explicando el código</h4>
<h5>Inicialización</h5>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="javascript" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> charset<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;utf-8&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #006600; font-style: italic;">// &lt;![CDATA[</span>
	<span style="color: #006600; font-style: italic;">// jQuery sin conflicto con la función de dólar de otras librerías</span>
	jQuery<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// Init vars: PUB_URL es una variable propia en otro sitio</span>
		<span style="color: #003366; font-weight: bold;">var</span> apiKey		<span style="color: #339933;">=</span> <span style="color: #3366CC;">'CLAVE_DE_TU_APLICACIÓN_PARA_ACCEDER_A_LA_API'</span><span style="color: #339933;">;</span>	<span style="color: #006600; font-style: italic;">// API KEY Facebook</span>
		<span style="color: #003366; font-weight: bold;">var</span> channelPath	<span style="color: #339933;">=</span> PUB_URL <span style="color: #339933;">+</span> <span style="color: #3366CC;">'/xd_receiver.htm'</span><span style="color: #339933;">;</span>						<span style="color: #006600; font-style: italic;">// Url a tu xd_receiver.html</span></pre></td></tr></table></div>

<p><strong>xd_receiver</strong>: A mí al menos me funciona tanto con rutas relativas como con absolutas pero tienes que tener cuidado, si usas redirecciones de cualquier tipo, mod_rewritte, wordpress&#8230;<br />
En mi opinión la mejor forma de comprobarlo es hacer una llamada AJAX al archivo a ver si obtienes una respuesta correcta<br />
<tt>200 OK</tt> al menos. Ej:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;">jQuery.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'tu_receiver_url'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// O prueba con post</span></pre></div></div>

<h5>Estado: Desconectado</h5>
<p><strong>Desconectado</strong>: Se puede generar FBML, XHTML&#8230; Yo recomiendo usar FBML siempre que sea posible para evitar problemas, por ejemplo de carga del DOM por otras librerías si se usan -ej. jQuery- y la de Facebook. Obviamente, esto se puede -y debe- mejorar, crear un plugin jQuery&#8230; pero eso ahora no corresponde.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="javascript" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;">		<span style="color: #009966; font-style: italic;">/* DESCONECTADO */</span>
		<span style="color: #006600; font-style: italic;">// Mostrar login:</span>
		<span style="color: #003366; font-weight: bold;">function</span> fbNotConnected<span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#facebookLogin'</span><span style="color: #009900;">&#41;</span>
			.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'pointer'</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// Clase CSS que añade el cursor correspondiente al botón padre span.</span>
			.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;fb:login-button size=&quot;medium&quot; length=&quot;long&quot; /&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #006600; font-style: italic;">// Parsear el DOM FB</span>
			FB.<span style="color: #660066;">XFBML</span>.<span style="color: #660066;">Host</span>.<span style="color: #660066;">parseDomTree</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h5>Estado: Desconectado, versión DOM</h5>
<p>Ejemplo rápido DOM. Ojo, se puede usar la librería de gestión del DOM de Facebook, pero yo aún no la he mirado. Sé que al menos usa la «función del dólar».</p>
<p><strong>Desconectado</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="javascript" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;">		<span style="color: #009966; font-style: italic;">/* DESCONECTADO */</span>
		<span style="color: #006600; font-style: italic;">// Mostrar login:</span>
		<span style="color: #003366; font-weight: bold;">function</span> fbNotConnected<span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> userBoxLogin <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'facebookLogin'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			userBoxLogin.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'style'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'cursor:pointer'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// cursor:hand para IE.</span>
			<span style="color: #006600; font-style: italic;">// Es un coñazo -y más con namespace extras- pero no voy a usar el puto innerHTML de M$</span>
			<span style="color: #003366; font-weight: bold;">var</span> fbLogin <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElementNS</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'http://www.facebook.com/2008/fbml'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'fb:login-button'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #006600; font-style: italic;">// Atributos, imagino, que no registrados xhtml:</span>
			fbLogin.<span style="color: #660066;">setAttributte</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'size'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'medium'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			fbLogin.<span style="color: #660066;">setAttributte</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'length'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'long'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			userBoxLogin.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>fbLogin<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #006600; font-style: italic;">// Parsear el DOM FB</span>
			FB.<span style="color: #660066;">XFBML</span>.<span style="color: #660066;">Host</span>.<span style="color: #660066;">parseDomTree</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><tt>result</tt> es opcional, debería devolver un <tt>null</tt>.</p>
<p>Básicamente generamos marcado Facebook (FBML) al vuelo, con jQuery si el usuario no está conectado y lo parseamos con la librería de Facebook.<br />
Muy importante: Como ya dije, necesitas un Namespace extra para el mismo, tu documento debe soportarlo y, como siempre y en cualquier caso, ¡estar bien formado! <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  <del datetime="2010-01-16T09:54:13+00:00" title="Ver aviso inicial">Yo, como buen talibán XML y anti M$ que soy, recomiendo XHTML1.1 de verdad, es decir, servir application/xhtml+xml que soporta XML</del>, pero ojo con Wordpress que la puede liar. Tú mismo; debería bastarte con un XHTML 1.0 Strict o Transicional.</p>
<p>Del resto se encarga la librería de Facebook al parsear el FBML, en este caso: generando el botón de login y su comportamiento. Se le puede añadir incluso una gestión de login/out -atributo <tt>autologoutlink="(bool)"</tt>-, aunque he preferido hacer el cambio yo mismo.</p>
<h5>Estado: Conectado</h5>
<dl>
<dt><strong>1.</strong> Generar la userbox del usuario y las opciones pertinentes.</dt>
<dd>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="javascript" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;">		<span style="color: #009966; font-style: italic;">/* CONECTADO */</span>
		<span style="color: #006600; font-style: italic;">// Update userbox:</span>
		<span style="color: #003366; font-weight: bold;">function</span> fbConnected<span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> api			<span style="color: #339933;">=</span> FB.<span style="color: #660066;">Facebook</span>.<span style="color: #660066;">apiClient</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> userUid		<span style="color: #339933;">=</span> api.<span style="color: #660066;">get_session</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">uid</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">// Html + FBML:</span>
			<span style="color: #003366; font-weight: bold;">var</span> htmlLogin 	<span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;span&gt;'</span>
			<span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;fb:profile-pic uid=&quot;loggedinuser&quot; facebook-logo=&quot;true&quot; linked=&quot;false&quot; class=&quot;alignleft&quot; /&gt;'</span>
			<span style="color: #339933;">+</span> <span style="color: #3366CC;">'Bienvenido &lt;fb:name uid=&quot;loggedinuser&quot; useyou=&quot;false&quot; /&gt;'</span>
			<span style="color: #339933;">+</span> <span style="color: #3366CC;">', estás conectado con tu cuenta de Facebook.'</span>
			<span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;fb:user uid=&quot;loggedinuser&quot; /&gt;&lt;fb:website uid=&quot;loggediuserin&quot; /&gt;'</span><span style="color: #339933;">;</span>
			<span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/span&gt;'</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> htmlLogout 	<span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;a class=&quot;pointer&quot; title=&quot;Desconectar de tu cuenta Facebook y esta web.&quot; '</span>
			<span style="color: #339933;">+</span> <span style="color: #3366CC;">'onclick=&quot;FB.Connect.logoutAndRedirect(<span style="color: #000099; font-weight: bold;">\'</span>&lt;?php the_permalink(); ?&gt;<span style="color: #000099; font-weight: bold;">\'</span>); return false;&quot;&gt;'</span>
			<span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;img alt=&quot;Logout&quot; src=&quot;http://static.ak.fbcdn.net/rsrc.php/zDUG0/hash/3g5yiwv5.gif&quot;&gt;&lt;/a&gt;'</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

</dd>
<dt><strong>2.</strong> Lo más importante: Conseguir un formulario útil y coherente.</dt>
<dt><strong>2.a</strong> En este sentido existe el problema, que por añadidura es una gran ventaja para los usuarios Facebook, de los permisos para el correo.</dt>
<dd>En concreto, Facebook no distribuye emails de usuarios lo cual me parece absolutamente necesario y genial.<br />
Solo ofrece un servicio comunicación proxy de emails a través de hashes o cadenas codificadas de los mismos que ellos de/codifican. Todo ello en el caso de obtener el permiso del usuario para que nuestra aplicación acceda al servicio de emails; permiso el cual solo es una cuestión ética, ya que podemos obtener la dirección proxy del email, aunque no nos va a servir de nada, al menos hasta que alguien decida intentar conocer la forma en que se codifican.</dd>
<dd>En resumen: Nunca nos van a dar el mail, solo el acceso al servicio.</dd>
<dt><strong>2.b</strong> Otras implementaciones que he visto no realizan lo siguiente; y los plugins, como digo, no me gustan y son muy pesados. Se limitan a enviar un nombre.</dt>
<dd>Nosotros obtendremos el nombre del usuario, un correo sustancialmente inútil pero válido en nuestro caso: id del usuario + cuenta facebook y otros campos a gusto del consumidor: Sitio web del perfil de Facebook, url del perfil, imagen&#8230;</p>
<p>Más detalles en este sentido con una simple búsqueda web por Facebook Connect: users.getInfo, users.getStandarInfo&#8230;, FQL User Tables, etc.</dd>
<dt><strong>3.b</strong> Por fin, rellenaremos el formulario vía JavaScrit y jQuery a ser posible, aunque podemos usar el DOM puro y duro.</dt>
<dd>Aquí ya depende de cada uno como hacerlo:<br />
	Se pueden rellenar los campos de forma visible al usuario para que pueda modificarlo si quiere, -lo más correcto y honesto-.<br />
	Se pueden rellenar de forma silenciosa para evitar cambios no deseados -en la mayoría de los casos el usuario no sabrá cambiarlos aunque es perfectamente posible-.<br />
	Se pueden rellenar justo al enviar el formulario -la forma más vil <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_mrgreen.gif' alt=':mrgreen:' class='wp-smiley' />  aunque se me ocurren otras como es lógico-.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
</pre></td><td class="code"><pre class="javascript" style="font-family:Consolas, Monaco, 'Lucida Sans Typewriter', 'Lucida Console', 'Andale Mono', monospace;">			<span style="color: #006600; font-style: italic;">// Obtener el nombre:</span>
			api.<span style="color: #660066;">users_getInfo</span><span style="color: #009900;">&#40;</span>userUid<span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'name'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'website'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'profile_url'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>res<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				fbGenerateFormField<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'author'</span><span style="color: #339933;">,</span> res<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				fbGenerateFormField<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'email'</span><span style="color: #339933;">,</span> userUid <span style="color: #339933;">+</span> <span style="color: #3366CC;">'@facebook.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #006600; font-style: italic;">// Opcionales: Se pueden forzar o dejar para rellenar por el usuario</span>
				<span style="color: #006600; font-style: italic;">// Sitio Web: Url del sitio web establecido en el perfil o el propio perfil.</span>
				<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'string'</span> <span style="color: #339933;">===</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>res<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">website</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#commentform input#url'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'value'</span><span style="color: #339933;">,</span> res<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">website</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #006600; font-style: italic;">// Forzar: fbUpdateFormField('url', res[0].website);</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'string'</span> <span style="color: #339933;">===</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>res<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">profile_url</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#commentform input#url'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'value'</span><span style="color: #339933;">,</span> res<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">profile_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #006600; font-style: italic;">// Forzar: fbUpdateFormField('url', res[0].profile_url);</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">// Cambiar la userbox:</span>
			jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#facebookLogin'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>htmlLogout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#userBox'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>htmlLogin<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#userMail'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #006600; font-style: italic;">// Parsear el DOM FB</span>
			FB.<span style="color: #660066;">XFBML</span>.<span style="color: #660066;">Host</span>.<span style="color: #660066;">parseDomTree</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #006600; font-style: italic;">// Helper: Crear nuevos campos en el formulario:</span>
		<span style="color: #003366; font-weight: bold;">function</span> fbGenerateFormField<span style="color: #009900;">&#40;</span>elId<span style="color: #339933;">,</span> value<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> formField <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;input id=&quot;'</span> <span style="color: #339933;">+</span> elId <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot; name=&quot;'</span> <span style="color: #339933;">+</span> elId <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot; value=&quot;'</span> <span style="color: #339933;">+</span> value <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot; type=&quot;hidden&quot; /&gt;'</span><span style="color: #339933;">;</span>
			jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'form#commentform'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>formField<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">// Init setup:</span>
		FB.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span>apiKey<span style="color: #339933;">,</span> channelPath<span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #3366CC;">&quot;ifUserConnected&quot;</span> <span style="color: #339933;">:</span> 	fbConnected<span style="color: #339933;">,</span> 
			<span style="color: #3366CC;">&quot;ifUserNotConnected&quot;</span> <span style="color: #339933;">:</span> 	fbNotConnected
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #006600; font-style: italic;">// End jQuery</span>
<span style="color: #006600; font-style: italic;">// ]]&gt;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

</dd>
</dl>
<p> <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  &#8230;bueno, al final no ha salido tan <em>breve</em> ni <em>rápido</em> <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_mrgreen.gif' alt=':mrgreen:' class='wp-smiley' />  . Ya haré una versión corta y una demo.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.culturadigital.org/tecnologia/desarrollo-web/breve-tutorial-facebook-connect-rapido-de-verdad/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Zend_Loader y Zend_Application, ZF1.8</title>
		<link>http://blog.culturadigital.org/tecnologia/desarrollo-web/zend_loader-y-zend_application-zf18</link>
		<comments>http://blog.culturadigital.org/tecnologia/desarrollo-web/zend_loader-y-zend_application-zf18#comments</comments>
		<pubDate>Wed, 06 May 2009 07:48:09 +0000</pubDate>
		<dc:creator>J.A.Cobo</dc:creator>
				<category><![CDATA[Desarrollo web]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://blog.culturadigital.org/?p=495</guid>
		<description><![CDATA[Más que nada esta anotación es un post-it para actualizar la plantilla «TemplateBase».
Vía el nuevo nivel de reporte de errores STRICT que usa php5 y Zend Framework, me entero de que Zend_Loader está depreciado desde esta nueva -y fantástica- versión 1.8.
&#8230;la cual, por otra parte, me ha sorprendido muy gratamente gracias a temas como Zend_Tool [...]]]></description>
			<content:encoded><![CDATA[<p>Más que nada esta anotación es un post-it para actualizar la plantilla «TemplateBase».</p>
<p>Vía el nuevo nivel de reporte de errores STRICT que usa php5 y Zend Framework, me entero de que Zend_Loader está <em>depreciado</em> desde esta nueva -y fantástica- versión 1.8.<br />
&#8230;la cual, por otra parte, me ha sorprendido muy gratamente gracias a temas como Zend_Tool (<em>scaffolding al estilo Simphony, Ruby&#8230; algo que extrañaba ya no lo hubieran implementado</em>) o <a href="http://framework.zend.com/manual/en/zend.application.html">Zend_Application</a> de la que pende, por ejemplo, Zend_Module_Autoloader o la clase Bootstrap. Las tediosas tareas de inicialización -bootstrap- de nuestra aplicación ahora sobre una base sólida y estándar <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  ; o montarte un sistema modular totalmente funcional en segundos y con una estructura también estándar y basada en <a href="http://es.wikipedia.org/wiki/Espacio_de_nombres">NameSpaces</a> ^^!</p>
<p>&#8230; como mola; cada vez me gusta más. ¡Viva <a href="http://framework.zend.com/manual/">Zend Framework</a>! <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.culturadigital.org/tecnologia/desarrollo-web/zend_loader-y-zend_application-zf18/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Volviendo a los orígenes, ser minimalista</title>
		<link>http://blog.culturadigital.org/el-blog/volviendo-a-los-origenes-ser-minimalista</link>
		<comments>http://blog.culturadigital.org/el-blog/volviendo-a-los-origenes-ser-minimalista#comments</comments>
		<pubDate>Mon, 27 Apr 2009 09:23:54 +0000</pubDate>
		<dc:creator>J.A.Cobo</dc:creator>
				<category><![CDATA[Desarrollo web]]></category>
		<category><![CDATA[El Blog]]></category>
		<category><![CDATA[minimalista]]></category>

		<guid isPermaLink="false">http://blog.culturadigital.org/?p=490</guid>
		<description><![CDATA[Llevo tanto tiempo dedicando el desarrollo web a Wordpress que prácticamente se había convertido en la panacea y había olvidado mis primeros trabajos y las bases.
Empezar a utilizar en serio Zend Framework y POO con PHP me ha vuelto a abrir los ojos al margen de desarrollar nuevas secciones en el sitio web. No puedo [...]]]></description>
			<content:encoded><![CDATA[<p>Llevo tanto tiempo dedicando el desarrollo web a Wordpress que prácticamente se había convertido en la panacea y había olvidado mis primeros trabajos y las bases.</p>
<p>Empezar a utilizar en serio Zend Framework y POO con PHP me ha vuelto a abrir los ojos al margen de desarrollar nuevas secciones en el sitio web. No puedo negar que hace tiempo que el blog me gusta más bien poco, de hecho no hace mucho que ya lo abandoné una vez: hay pocas ganas de escribir sobre no muchas cosas&#8230; y si las hay, la experimentación sobre el diseño siempre acaba ganando sobre lo que de verdad quiero hacer en un blog: escribir y punto.</p>
<p>Este último theme de Wordpress me sirvió para trasladar aquí lo probado en el diseño de la web de La Guardia pero lo cierto es que ya estoy un poco harto de un diseño tan «empalogoso» <em class="x-small">Diseño, porque por lo demás -la aplicación- me encanta TemplateBase</em>.<br />
Quiero volver a los orígenes, a una lectura sencilla y cómoda, nada más.</p>
<p>De hecho, es posible que pronto incluso deje a un lado Wordpress para montarme algo sencillo con Zend FW, porque mientras más lo uso, más me gusta y más claro lo veo ^^!</p>
<p>Por lo pronto, voy a volver <del datetime="2009-04-27T23:16:14+00:00">a mi antiguo theme Standar WP</del> a otro algo menos recargado: <em>simpleCovi</em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.culturadigital.org/el-blog/volviendo-a-los-origenes-ser-minimalista/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHPTACO, tu aplicación base sobre Zend Framework</title>
		<link>http://blog.culturadigital.org/tecnologia/desarrollo-web/phptaco-tu-aplicacion-base-sobre-zend-framework</link>
		<comments>http://blog.culturadigital.org/tecnologia/desarrollo-web/phptaco-tu-aplicacion-base-sobre-zend-framework#comments</comments>
		<pubDate>Fri, 20 Mar 2009 10:01:39 +0000</pubDate>
		<dc:creator>J.A.Cobo</dc:creator>
				<category><![CDATA[Desarrollo web]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend]]></category>

		<guid isPermaLink="false">http://blog.culturadigital.org/?p=481</guid>
		<description><![CDATA[Anoche, buscando un esqueleto básico de aplicación web basado en Zen Framework, encontré PHPTACO.
Mi sorpresa (o decepción, según se mire) ha sido encontrar que se incluye PHPTAL que es un sistema de plantillas, o lo que es lo mismo: mi TemplateBase pero de forma profesional ^^! Eso confirma el tema de: «Busca, busca y luego [...]]]></description>
			<content:encoded><![CDATA[<p>Anoche, buscando un <a href="http://blog.realmofzod.com/2008/03/19/modular-zend-framework-application-skeleton-part-1-folder-structure/">esqueleto básico de aplicación web basado en Zen Framework</a>, encontré <a href="http://www.orsa-studio.com/phptaco/?p=1">PHPTACO</a>.<br />
Mi sorpresa (o decepción, según se mire) ha sido encontrar que se incluye PHPTAL que es un sistema de plantillas, o lo que es lo mismo: mi TemplateBase pero de forma profesional ^^! Eso confirma el tema de: «Busca, busca y luego busca más, porque seguramente ya esté fabricado» <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Así que pretendo experimentar con esta estructura base, algo que llevo intentando tener desde no poco tiempo. El problema es que hasta ahora, tenía varias estructuras base&#8230; digamos modulares y que en e fondo presentan algunos problemas, por ejemplo:</p>
<ul>
<li>Tengo una estructura base basada en Wordpress, que en mi opinión es perfecto para un CMS si lo conoces.</li>
<li>La más importante: tengo una estructura base para recursos estáticos en un servidor y sobre un subdominio habitualmente. Además de ésta última, también uso librerías y otros recursos globales o genéricos.</li>
</ul>
<h4>Problemas</h4>
<p>El problema al usar Zend Framework no es, o debería ser, algo como por ejemplo el tema de la propia librería de Zend, sino dicha estructura y sus recursos estáticos. Una aplicación sencilla o pequeña (como por ejemplo mis 1SCTools) montarla en base a esta aplicación base, ya sea como un módulo o en solitario, es demasiado pesado y no es útil más que, como decía, si ya tienes más aplicaciones montadas en tu aplicación general.</p>
<p>Con el tema de los recursos pasa igual y revela un problema de mi servidor estático: no siempre podrás montarlo así, o al menos, como subdominio aunque eso es lo menos importante. Eso sin olvidar que la mayoría de las aplicaciones web incorporan siempre dichos recursos lo que implica que siempre, siempre deberás adaptarlos y editar <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<h4>El eterno dilema</h4>
<p>Así pues, ahora me toca una de dos: Adaptar mis estructuras base a una sola basada en Zend, incluyendo servidor estático y tal o adaptar esta misma a las estructuras actuales.<br />
Y es por estas cuestiones por las que aún hoy no tengo un sistema base completo y robusto que me haga montar algo rápido con el mayor número de opciones <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<h5>Rewrite, servidores estáticos&#8230;</h5>
<p>Lo que además revela es mi incapacidad, aunque lo cierto es que ni lo he intentado, de escribir un&#8230; ¡ostias! gg, ahora mismo -y no es coña- acabo de acordarme del «<a href="http://framework.zend.com/manual/en/zend.controller.router.html">Zend Router</a>» que es un controlador para rewrite (véase por ejemplo el objeto Rewrite de Wordpress), que es a su vez de lo que precisamente iba a hablar ^^!</p>
<p>No obstante y si se analiza bien, el problema persiste, rewrite no lo soluciona ya que mi intención es usar subdominios estáticos desde que comprobé cómo mejoran las aplicaciones web en relación a rendimiento y optimización.<br />
Ese es el problema real: que es un coñazo montar una aplicación que albergue ambas posibilidades por no hablar de la duplicidad de recursos: Usar recursos internos de la aplicación y recursos basados en subdominios, lo cual empeora aún si, como suele ser habitual, se usan hostings compartidos.</p>
<p>En sitios propios no es un problema, pero si escribes algo para alguien, o una aplicación estándar para distribuir, es una auténtica locura <img src='http://blog.culturadigital.org/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  , si bien lo sencillo es usar recursos internos y punto.</p>
<p>En fin, por lo pronto, iré probando a montar algo base olvidándome de servidores estáticos, algo que por otra parte se está convirtiendo en un estándar.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.culturadigital.org/tecnologia/desarrollo-web/phptaco-tu-aplicacion-base-sobre-zend-framework/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
