<?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>Damián Culotta &#187; templates</title>
	<atom:link href="http://www.damianculotta.com.ar/tag/templates/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.damianculotta.com.ar</link>
	<description>Sería un &#34;bienvenidos a mi&#34;, pero Rozitchner me ganó de mano</description>
	<lastBuildDate>Thu, 05 Jan 2012 09:10:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Incluir archivos JS por layout según configuración en Magento</title>
		<link>http://www.damianculotta.com.ar/2010/12/16/incluir-archivos-js-por-layout-segun-configuracion-en-magento/</link>
		<comments>http://www.damianculotta.com.ar/2010/12/16/incluir-archivos-js-por-layout-segun-configuracion-en-magento/#comments</comments>
		<pubDate>Thu, 16 Dec 2010 06:30:29 +0000</pubDate>
		<dc:creator>Damián</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[programación]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.damianculotta.com.ar/?p=2014</guid>
		<description><![CDATA[Ya hemos visto como sobreescribir templates y cómo agregar archivos css de forma modular. Siguiendo con la idea de armar módulos que podamos reutilizar, vamos a ver cómo agregar archivos javascript pero sólo si hemos configurado desde el backend su &#8230; <a href="http://www.damianculotta.com.ar/2010/12/16/incluir-archivos-js-por-layout-segun-configuracion-en-magento/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Ya hemos visto como <a title="Sobreescribir templates en Magento desde el layout" href="http://www.damianculotta.com.ar/2010/12/05/sobreescribir-templates-en-magento-desde-el-layout/" target="_self">sobreescribir templates</a> y <a title="Cómo agregar un archivo CSS por layout en Magento" href="http://www.damianculotta.com.ar/2010/12/07/como-agregar-un-archivo-css-por-layout-en-magento/" target="_blank">cómo agregar archivos css de forma modular</a>.</p>
<p>Siguiendo con la idea de armar módulos que podamos reutilizar, vamos a ver cómo agregar archivos javascript pero sólo si hemos configurado desde el backend su inclusión.</p>
<p>Si antes aplicamos el método addCss, en ésta oportunidad tenemos dos formas de llamar a un archivo js.</p>
<p>El código a usar, si nuestro archivo js debe incluirse cada vez que se instancie nuestro módulo, sería el siguiente si es que el archivo se encuentra en la carpeta /skin.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;layout</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;0.1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    ...
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;head&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;addItem&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>skin_js<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>js/archivo.js<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    ...
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/layout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Y de ésta otra forma lo hacemos si es que estamos agregando una librería ubicada en /js.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;layout</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;0.1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    ...
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;head&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;addJs&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>carpeta/archivo.js<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    ...
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/layout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Supongamos ahora que armamos un módulo que requiere de una librería (para mi ejemplo y por preferencia, pensemos que es <a title="sitio oficial" href="http://jquery.com/" target="_self">jQuery</a>), pero que siendo la nuestra una extensión, podría pasarnos que al agregarla a un proyecto, jQuery ya se esté usando.</p>
<p><span id="more-2014"></span>La solución de artesano sería editar el código de nuestro módulo y quitar la llamada a ese javascript (algo que puede llegar a ser realmente tedioso si éste módulo lo reutilizáramos todo el tiempo).</p>
<p>Para resolver éste escenario, vamos a hacer uso de uno de los condicionales que podemos aplicar en el layout. En éste caso será el turno de ifconfig, que se encarga de validarse contra una key de configuración que le indiquemos.</p>
<p>Siguiendo con la idea de agregar una librería que podría o no estar presente, el código quedaría de la siguiente forma.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;layout</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;0.1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    ...
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;head&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;addJs&quot;</span> <span style="color: #000066;">ifconfig</span>=<span style="color: #ff0000;">&quot;javascript/jquery/custom&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>jquery/jquery.js<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    ...
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/layout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Para que esa key de configuración pueda ser editada, le agregamos a nuestro módulo la opción de configuración. En este caso, podría verse de la siguiente manera.</p>
<p><a href="http://www.damianculotta.com.ar/wp-content/uploads/2010-12-16-00-15-jquery-configuracion.png"><img class="aligncenter size-medium wp-image-2041" title="Incluyendo archivos de layout por configuración en Magento" src="http://www.damianculotta.com.ar/wp-content/uploads/2010-12-16-00-15-jquery-configuracion-300x38.png" alt="" width="300" height="38" /></a></p>
<p>Desde ahora, si cuando agregamos el módulo la librería que necesitamos no está siendo usada, activamos su uso mediante la configuración.</p>
<p>Si nos toca agregarla en un proyecto en el cual, por ejemplo, la librería ya es invocada desde el page.xml, no tendremos necesidad de modificar ningún archivo para evitar la doble instancia de la misma librería.</p>
 <img src="http://www.damianculotta.com.ar/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=2014" width="1" height="1" style="display: none;" /><h2  class="related_post_title">A lo mejor te interese leer</h2><ul class="related_post"><li><a href="http://www.damianculotta.com.ar/2011/11/07/mejorando-el-seo-de-nuestros-modulos-en-magento/" title="Mejorando el SEO de nuestros módulos en Magento">Mejorando el SEO de nuestros módulos en Magento</a></li><li><a href="http://www.damianculotta.com.ar/2011/10/10/agregar-validaciones-javascript-en-magento-de-forma-no-obstrusiva/" title="Agregar validaciones javascript en Magento de forma no obstrusiva">Agregar validaciones javascript en Magento de forma no obstrusiva</a></li><li><a href="http://www.damianculotta.com.ar/2011/09/12/configuraciones-dependientes-en-magento/" title="Configuraciones dependientes en Magento">Configuraciones dependientes en Magento</a></li><li><a href="http://www.damianculotta.com.ar/2011/08/17/como-agregar-atributos-a-una-categoria-en-magento/" title="Cómo agregar atributos a una categoría en Magento">Cómo agregar atributos a una categoría en Magento</a></li><li><a href="http://www.damianculotta.com.ar/2011/08/15/como-modificar-valores-de-configuracion-via-codigo-en-magento/" title="Cómo modificar valores de configuración vía código en Magento">Cómo modificar valores de configuración vía código en Magento</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.damianculotta.com.ar/2010/12/16/incluir-archivos-js-por-layout-segun-configuracion-en-magento/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Cómo agregar un archivo CSS por layout en Magento</title>
		<link>http://www.damianculotta.com.ar/2010/12/07/como-agregar-un-archivo-css-por-layout-en-magento/</link>
		<comments>http://www.damianculotta.com.ar/2010/12/07/como-agregar-un-archivo-css-por-layout-en-magento/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 04:15:33 +0000</pubDate>
		<dc:creator>Damián</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[programación]]></category>
		<category><![CDATA[templates]]></category>

		<guid isPermaLink="false">http://www.damianculotta.com.ar/?p=2007</guid>
		<description><![CDATA[Siguiendo un poco con el tema de las buenas prácticas en cuanto a maquetación, módulos y esas yerbas; vamos a ver cómo incluir un nuevo archivo css dentro de nuestro template. Básicamente tenemos dos formas (algunas más en realidad si &#8230; <a href="http://www.damianculotta.com.ar/2010/12/07/como-agregar-un-archivo-css-por-layout-en-magento/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Siguiendo un poco con el tema de las buenas prácticas en cuanto a maquetación, módulos y esas yerbas; vamos a ver cómo incluir un nuevo archivo css dentro de nuestro template.</p>
<p>Básicamente tenemos dos formas (algunas más en realidad si queremos hacer las cosas poco prolijas).</p>
<p>La primera y más extendida, sería tomar page.xml de nuestro layout y repetir, por ejemplo la siguiente línea.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;addCss&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;stylesheet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>css/mi_css.css<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/stylesheet<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Le cambiamos el nombre del archivo (que deberá estar ubicado en el path correcto) y con eso vamos a tener nuestro archivo css listo para ser leído.</p>
<p>La segunda forma de hacerlo, que nos sirve para nuestras extensiones, es hacer esto mismo pero desde la definición de layout del módulo.</p>
<p>Esto nos permitirá que sólo en los casos en los que el módulo se instancie, o incluso sólo en una sección, se agregue nuestro archivo css.</p>
<p>Dado que el archivo css ya lo tenemos ubicado dentro de las carpeta de skin correspondiente, vamos a agregar la definición a nuestro módulo.</p>
<p>Vamos a suponer que el módulo se llama Noticias. Normalmente, encontraríamos dentro de la carpeta de layout del frontend un archivo noticias.xml.</p>
<p>Dentro de ese archivo tenemos que agregar las siguientes líneas.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;layout</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;0.1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    ...
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;head&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;addCss&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>noticias.css<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    ...
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/layout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>De ésta forma le decimos que tome el bloque &#8220;head&#8221; (que se encuentra definido en page.xml) y agregue un archivo css. Luego se le pasa el path al archivo que puede ser cualquiera dentro de la carpeta de skin the nuestro theme.</p>
 <img src="http://www.damianculotta.com.ar/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=2007" width="1" height="1" style="display: none;" /><h2  class="related_post_title">A lo mejor te interese leer</h2><ul class="related_post"><li><a href="http://www.damianculotta.com.ar/2010/12/16/incluir-archivos-js-por-layout-segun-configuracion-en-magento/" title="Incluir archivos JS por layout según configuración en Magento">Incluir archivos JS por layout según configuración en Magento</a></li><li><a href="http://www.damianculotta.com.ar/2010/12/05/sobreescribir-templates-en-magento-desde-el-layout/" title="Sobreescribir templates en Magento desde el layout">Sobreescribir templates en Magento desde el layout</a></li><li><a href="http://www.damianculotta.com.ar/2011/11/07/mejorando-el-seo-de-nuestros-modulos-en-magento/" title="Mejorando el SEO de nuestros módulos en Magento">Mejorando el SEO de nuestros módulos en Magento</a></li><li><a href="http://www.damianculotta.com.ar/2011/10/10/agregar-validaciones-javascript-en-magento-de-forma-no-obstrusiva/" title="Agregar validaciones javascript en Magento de forma no obstrusiva">Agregar validaciones javascript en Magento de forma no obstrusiva</a></li><li><a href="http://www.damianculotta.com.ar/2011/09/12/configuraciones-dependientes-en-magento/" title="Configuraciones dependientes en Magento">Configuraciones dependientes en Magento</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.damianculotta.com.ar/2010/12/07/como-agregar-un-archivo-css-por-layout-en-magento/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sobreescribir templates en Magento desde el layout</title>
		<link>http://www.damianculotta.com.ar/2010/12/05/sobreescribir-templates-en-magento-desde-el-layout/</link>
		<comments>http://www.damianculotta.com.ar/2010/12/05/sobreescribir-templates-en-magento-desde-el-layout/#comments</comments>
		<pubDate>Sun, 05 Dec 2010 23:35:06 +0000</pubDate>
		<dc:creator>Damián</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[programación]]></category>
		<category><![CDATA[templates]]></category>

		<guid isPermaLink="false">http://www.damianculotta.com.ar/?p=1992</guid>
		<description><![CDATA[Una de las grandes bondades (y de los grandes problemas en el comienzo de la curva de aprendizaje) es el manejo de los templates a través de las definiciones xml del layout. Normalmente, cuando trabajamos con un skin desde el &#8230; <a href="http://www.damianculotta.com.ar/2010/12/05/sobreescribir-templates-en-magento-desde-el-layout/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Una de las grandes bondades (y de los grandes problemas en el comienzo de la curva de aprendizaje) es el manejo de los templates a través de las definiciones xml del layout.</p>
<p>Normalmente, cuando trabajamos con un skin desde el comienzo, más allá de las líneas de diseño que puedan existir, tenemos bastante libertad de elección en la forma en que se va estructurar ese theme.</p>
<p>Ahora bien, cambia radicalmente el escenario cuando nos dedicamos a crear extensiones o cuando ciertas customizaciones que hayamos desarrollado se tornan parte de la batería de módulos y ajustes que usamos en cada proyecto.</p>
<p>Si para cada caso debiéramos estar modificando los archivos phtml, los xml, el css&#8230; bueno, sería bastante molesto y estaríamos dejando de tener código reutilizable.</p>
<p>A través de las definiciones de layout podemos aplicar cambios al momento de renderear el template sin hacer modificaciones a los archivos que ya se estén usando. En realidad, hay unas cuantas cosas que pueden hacerse, pero dada la cantidad de funciones con las que contamos para el manejo del layout, sólo me voy a centrar en el reemplazo de llamadas a los phtml.</p>
<p>Como ejemplo, vamos a tomar el selector de moneda. Vamos a suponer también que tenemos definido el update de layout en el módulo.</p>
<p><span id="more-1992"></span>Ahora bien, el selector de moneda (suponiendo que nuestra tienda posee más de una y lo tenemos cofigurado) se muestra en varias secciones. En el archivo /app/design/frontend/base/default/layout/directory.xml tenemos todas las indicaciones.</p>
<p>Para el ejemplo, vamos a usar la llamada que se utiliza en la vista de categoría.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;layout</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;0.1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    ...
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;catalog_category_default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;left&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;block</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;directory/currency&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;currency&quot;</span> <span style="color: #000066;">before</span>=<span style="color: #ff0000;">&quot;catalog.leftnav&quot;</span> <span style="color: #000066;">template</span>=<span style="color: #ff0000;">&quot;directory/currency.phtml&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/catalog_category_default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    ...
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/layout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Podemos ver que al bloque referenciado como &#8220;currency&#8221; se le asigna el template &#8220;directory/currency.phtml&#8221;.</p>
<p>Para hacer nuestro reemplazo sin alterar archivo alguno, tenemos que hacer uso del método setTemplate, que se encargará de reasignar un nuevo phtml al mismo bloque. Supongamos que la definición de layout de nuestro módulo estuviera en un archivo llamado currency.xml, el mismo debería tener la siguiente definición para aplicar el cambio.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;layout</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;0.1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    ...
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;catalog_category_default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;currency&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;setTemplate&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;template<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>path/a/mi/nuevo/currency.phtml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/template<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/catalog_category_default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    ...
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/layout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Con ésta nueva definición, lo que estamos haciendo es indicar que en la vista de categoría, se busque el bloque llamado &#8220;currency&#8221; y se cambie el template por este que hemos definido.</p>
<p>De ésta forma, estamos haciendo una sobreescritura no intrusiva.</p>
 <img src="http://www.damianculotta.com.ar/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1992" width="1" height="1" style="display: none;" /><h2  class="related_post_title">A lo mejor te interese leer</h2><ul class="related_post"><li><a href="http://www.damianculotta.com.ar/2010/12/16/incluir-archivos-js-por-layout-segun-configuracion-en-magento/" title="Incluir archivos JS por layout según configuración en Magento">Incluir archivos JS por layout según configuración en Magento</a></li><li><a href="http://www.damianculotta.com.ar/2010/12/07/como-agregar-un-archivo-css-por-layout-en-magento/" title="Cómo agregar un archivo CSS por layout en Magento">Cómo agregar un archivo CSS por layout en Magento</a></li><li><a href="http://www.damianculotta.com.ar/2011/11/07/mejorando-el-seo-de-nuestros-modulos-en-magento/" title="Mejorando el SEO de nuestros módulos en Magento">Mejorando el SEO de nuestros módulos en Magento</a></li><li><a href="http://www.damianculotta.com.ar/2011/10/10/agregar-validaciones-javascript-en-magento-de-forma-no-obstrusiva/" title="Agregar validaciones javascript en Magento de forma no obstrusiva">Agregar validaciones javascript en Magento de forma no obstrusiva</a></li><li><a href="http://www.damianculotta.com.ar/2011/09/12/configuraciones-dependientes-en-magento/" title="Configuraciones dependientes en Magento">Configuraciones dependientes en Magento</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.damianculotta.com.ar/2010/12/05/sobreescribir-templates-en-magento-desde-el-layout/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Variable media en las plantillas de email de Magento</title>
		<link>http://www.damianculotta.com.ar/2009/05/22/variable-media-en-las-plantillas-de-email-de-magento/</link>
		<comments>http://www.damianculotta.com.ar/2009/05/22/variable-media-en-las-plantillas-de-email-de-magento/#comments</comments>
		<pubDate>Fri, 22 May 2009 03:01:45 +0000</pubDate>
		<dc:creator>Damián</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[configuración]]></category>
		<category><![CDATA[diseño]]></category>
		<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[templates]]></category>

		<guid isPermaLink="false">http://www.damianculotta.com.ar/?p=1359</guid>
		<description><![CDATA[Uno de los pocos cambios de la nueva versión de la plataforma, consiste en el agregado de la variable &#8220;media&#8221; para la composición de los templates de email. Su uso es absolutamente sencillo. Al igual que cuando invocamos {{skin url=&#8221;"}} &#8230; <a href="http://www.damianculotta.com.ar/2009/05/22/variable-media-en-las-plantillas-de-email-de-magento/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Uno de los pocos cambios de la nueva versión de la plataforma, consiste en el agregado de la variable &#8220;media&#8221; para la composición de los templates de email.</p>
<p>Su uso es absolutamente sencillo.</p>
<p>Al igual que cuando invocamos {{skin url=&#8221;"}} para imprimir algún contenido de un skin dado, la variable media utiliza el mismo parámetro.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;{{media url=&quot;</span>imagen.jpg<span style="color: #ff0000;">&quot;}}&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Magento&quot;</span> <span style="color: #000066;">border</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span></pre></div></div>

<p>Esto hará que se busque la imagen dentro de la carpeta media. Si usáramos subcarpetas, deberemos escribir el path partiendo siempre desde dicha carpeta.</p>
<p>Si bien puede parecer una pavada la inclusión del template, su uso puede entenderse en el caso de campañas de promoción, en las cuales podríamos utilizar (es sólo un ejemplo para graficar) el mismo banner que tenemos en la home de la tienda, en el cuerpo del mail.</p>
 <img src="http://www.damianculotta.com.ar/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1359" width="1" height="1" style="display: none;" /><h2  class="related_post_title">A lo mejor te interese leer</h2><ul class="related_post"><li><a href="http://www.damianculotta.com.ar/2009/05/21/eligiendo-el-skin-para-las-plantillas-de-email-en-magento/" title="Eligiendo el Skin para las plantillas de Email en Magento">Eligiendo el Skin para las plantillas de Email en Magento</a></li><li><a href="http://www.damianculotta.com.ar/2009/07/11/mostrar-phtmls-y-bloques-usados-en-el-skin-de-backend-de-magento/" title="Mostrar phtmls y bloques usados en el skin de backend de Magento">Mostrar phtmls y bloques usados en el skin de backend de Magento</a></li><li><a href="http://www.damianculotta.com.ar/2008/09/27/mostrar-los-bloques-html-en-el-frontend-de-magento/" title="Mostrar los bloques html en el frontend de Magento">Mostrar los bloques html en el frontend de Magento</a></li><li><a href="http://www.damianculotta.com.ar/2011/01/20/configurar-la-cantidad-de-registros-por-defecto-en-una-grilla/" title="Configurar la cantidad de registros por defecto en una grilla">Configurar la cantidad de registros por defecto en una grilla</a></li><li><a href="http://www.damianculotta.com.ar/2010/12/16/incluir-archivos-js-por-layout-segun-configuracion-en-magento/" title="Incluir archivos JS por layout según configuración en Magento">Incluir archivos JS por layout según configuración en Magento</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.damianculotta.com.ar/2009/05/22/variable-media-en-las-plantillas-de-email-de-magento/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eligiendo el Skin para las plantillas de Email en Magento</title>
		<link>http://www.damianculotta.com.ar/2009/05/21/eligiendo-el-skin-para-las-plantillas-de-email-en-magento/</link>
		<comments>http://www.damianculotta.com.ar/2009/05/21/eligiendo-el-skin-para-las-plantillas-de-email-en-magento/#comments</comments>
		<pubDate>Thu, 21 May 2009 03:05:13 +0000</pubDate>
		<dc:creator>Damián</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[configuración]]></category>
		<category><![CDATA[diseño]]></category>
		<category><![CDATA[ecommerce]]></category>
		<category><![CDATA[templates]]></category>

		<guid isPermaLink="false">http://www.damianculotta.com.ar/?p=1343</guid>
		<description><![CDATA[Una de las virtudes de Magento, es que a nivel funcional tiene cubiertos tantos temas que pareciera que uno no necesita nada más. Una de sus contras, es que al momento de necesitar una mínima personalización, uno puede terminar sintiéndose &#8230; <a href="http://www.damianculotta.com.ar/2009/05/21/eligiendo-el-skin-para-las-plantillas-de-email-en-magento/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Una de las virtudes de <a title="la evolución del eCommerce" href="http://www.magentocommerce.com/" target="_self">Magento</a>, es que a nivel funcional tiene cubiertos tantos temas que pareciera que uno no necesita nada más.</p>
<p>Una de sus contras, es que al momento de necesitar una mínima personalización, uno puede terminar sintiéndose perseguido por una multitud de líneas de código corriendo en círculos.</p>
<p>Hoy vamos a ver un pequeño truco, detalle, &#8230;&#8230; (complete la línea punteada con la palabra que mejor le resulte); que sirve para indicarle a la plantilla, de qué skin tomará las imagenes que se mostrarán en el caso de las plantillas html.</p>
<p>Si ya les tocó tener que personalizar esas plantillas, es probable que hayan visto dentro del código que imprime el logotipo, una línea parecida a la siguiente.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">valign</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;top&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;{{store url=&quot;</span><span style="color: #ff0000;">&quot;}}&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;{{skin url=&quot;</span>images<span style="color: #66cc66;">/</span>logo_email.gif<span style="color: #ff0000;">&quot; _area='frontend'}}&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Magento&quot;</span>  <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;margin-bottom:10px;&quot;</span> <span style="color: #000066;">border</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span></pre></div></div>

<p>Un repaso rápido de las variables usadas:</p>
<ul>
<li>{{store url=&#8221;"}} es el base_url de la tienda. Por ejemplo: http://www.mitienda.com.ar/</li>
<li>{{skin url=&#8221;&#8230;&#8221;}} transforma el source de la imagen a http://www.mitienda.com.ar/skin/frontend/default/default/ y le concatena images/logo_email.gif. Nos quedaría la siguiente url: http://www.mitienda.com.ar/skin/frontend/default/default/images/logo_email.gif.</li>
<li>{{skin url}} aplica una directiva: _area=&#8217;frontend&#8217;. Como vimos en el punto anterior, la imagen es tomada desde &#8230;/skin/frontend/. Si el valor de _area lo cambiamos por _area=&#8217;adminhtml&#8217;, el template buscará la imagen dentro del contenido del skin default/default del backend.</li>
</ul>
<p>Hasta acá tenemos lo que a simple vista se ve y más o menos podíamos suponer.</p>
<p><span id="more-1343"></span>Para la variable {{skin url}} tenemos dos directivas adicionales, no documentadas, que nos dan un poco más de flexibilidad. Un ejemplo podría ser:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;{{skin url=&quot;</span>images<span style="color: #66cc66;">/</span>logo_email.gif<span style="color: #ff0000;">&quot; _area='frontend' _package='paquete' _theme='tema'}}&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Magento&quot;</span>  <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;margin-bottom:10px;&quot;</span> <span style="color: #000066;">border</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #66cc66;">/</span>&gt;</span></pre></div></div>

<p>Las dos &#8220;nuevas&#8221; directivas funcionan de la siguiente manera.</p>
<ul>
<li>_package=&#8217;paquete&#8217; determina de que paquete del skin se está hablando. Recuerden que los skins pueden estar conformados por múltiples paquetes con múltiples temas cada uno. Si usáramos como skin default/blue, default sería el paquete y blue el tema.</li>
<li>_theme=&#8217;tema&#8217; hace exactamente lo mismo pero, obviedad mediante, a nivel tema.</li>
</ul>
<p>De ésta forma, podríamos estar usando un skin determinado para nuestra tienda, y podríamos usar imagenes de otro skin en nuestros templates. En realidad, podríamos hacer tantas combinaciones y configuraciones como complicaciones o requerimientos nos lleguen.</p>
 <img src="http://www.damianculotta.com.ar/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1343" width="1" height="1" style="display: none;" /><h2  class="related_post_title">A lo mejor te interese leer</h2><ul class="related_post"><li><a href="http://www.damianculotta.com.ar/2009/05/22/variable-media-en-las-plantillas-de-email-de-magento/" title="Variable media en las plantillas de email de Magento">Variable media en las plantillas de email de Magento</a></li><li><a href="http://www.damianculotta.com.ar/2009/07/11/mostrar-phtmls-y-bloques-usados-en-el-skin-de-backend-de-magento/" title="Mostrar phtmls y bloques usados en el skin de backend de Magento">Mostrar phtmls y bloques usados en el skin de backend de Magento</a></li><li><a href="http://www.damianculotta.com.ar/2008/09/27/mostrar-los-bloques-html-en-el-frontend-de-magento/" title="Mostrar los bloques html en el frontend de Magento">Mostrar los bloques html en el frontend de Magento</a></li><li><a href="http://www.damianculotta.com.ar/2011/01/20/configurar-la-cantidad-de-registros-por-defecto-en-una-grilla/" title="Configurar la cantidad de registros por defecto en una grilla">Configurar la cantidad de registros por defecto en una grilla</a></li><li><a href="http://www.damianculotta.com.ar/2010/12/16/incluir-archivos-js-por-layout-segun-configuracion-en-magento/" title="Incluir archivos JS por layout según configuración en Magento">Incluir archivos JS por layout según configuración en Magento</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.damianculotta.com.ar/2009/05/21/eligiendo-el-skin-para-las-plantillas-de-email-en-magento/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

