<?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>Isern Palaus</title>
	<atom:link href="http://blog.ipalaus.es/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.ipalaus.es</link>
	<description>PHP, CodeIgniter y jQuery</description>
	<lastBuildDate>Sat, 10 Apr 2010 13:10:51 +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>CodeIgniter: Goo.gl helper</title>
		<link>http://blog.ipalaus.es/codeigniter-goo-gl-helper</link>
		<comments>http://blog.ipalaus.es/codeigniter-goo-gl-helper#comments</comments>
		<pubDate>Sat, 10 Apr 2010 13:10:51 +0000</pubDate>
		<dc:creator>Isern Palaus</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.ipalaus.es/?p=67</guid>
		<description><![CDATA[Estoy planeando en publicar mi sistema de tienda virtual que he programado en CodeIgniter como open-source&#8230; de modo que quiero familiarizarme con las herramientas publicas tipo Git/bitbucket. He decidido crear un perfil y probar con un simple repositorio: codeigniter-googl-helper (con la convención de nombres propuesta por jamierumbelow).
El uso es muy sencillo: necesitas cargar el helper <a href="http://blog.ipalaus.es/codeigniter-goo-gl-helper" class="more-link">Más &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Estoy planeando en publicar mi sistema de tienda virtual que he programado en CodeIgniter como open-source&#8230; de modo que quiero familiarizarme con las herramientas publicas tipo Git/bitbucket. He decidido crear un perfil y probar con un simple repositorio: <a href="http://bitbucket.org/ipalaus/codeigniter-googl-helper/">codeigniter-googl-helper</a> (con la <a href="http://jamieonsoftware.com/blog/entry/codeigniter-repo-naming-conventions">convención de nombres propuesta por jamierumbelow</a>).</p>
<div id="wpshdo_1" class="wp-synhighlighter-outer"><div id="wpshdt_1" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_1"></a><a id="wpshat_1" class="wp-synhighlighter-title" href="#codesyntax_1"  onClick="javascript:wpsh_toggleBlock(1)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_about(1)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_1" class="wp-synhighlighter-inner" style="display: block;"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #009933; font-style: italic;">/**<br />
&nbsp;* A helper to create easy Goo.gl short urls<br />
&nbsp;*<br />
&nbsp;* @package &nbsp; &nbsp; CodeIgniter<br />
&nbsp;* @subpackage &nbsp;Googl_Helper<br />
&nbsp;* @license &nbsp; &nbsp; GPLv3 &lt;http://www.gnu.org/licenses/gpl-3.0.txt&gt;<br />
&nbsp;* @link &nbsp; &nbsp;&nbsp; &nbsp; http://bitbucket.org/ipalaus/codeigniter-googl-helper/<br />
&nbsp;* @link&nbsp; &nbsp; &nbsp; &nbsp; http://ggl-shortener.appspot.com/instructions/<br />
&nbsp;* @version &nbsp; &nbsp; 1.0<br />
&nbsp;* @author &nbsp;&nbsp; &nbsp; Isern Palaus &lt;http://blog.ipalaus.es&gt;<br />
&nbsp;* @copyright &nbsp; Copyright (c) 2010, Isern Palaus &lt;http://blog.ipalaus.es&gt;<br />
&nbsp;*/</span><br />
<br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'googl_url'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> googl_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$long_url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$secure</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$curl</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/curl_init"><span style="color: #990000;">curl_init</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://ggl-shortener.appspot.com/?url='</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/rawurlencode"><span style="color: #990000;">rawurlencode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$long_url</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/curl_setopt"><span style="color: #990000;">curl_setopt</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/curl_exec"><span style="color: #990000;">curl_exec</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$json_response</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/json_decode"><span style="color: #990000;">json_decode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$json_response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">error_message</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$json_response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">short_url</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$secure</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$long_url</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/curl_close"><span style="color: #990000;">curl_close</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$secure</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$long_url</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$return</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>El uso es muy sencillo: necesitas cargar el <em>helper</em> y usar la función <strong>googl_url()</strong>:</p>
<div id="wpshdo_2" class="wp-synhighlighter-outer"><div id="wpshdt_2" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_2"></a><a id="wpshat_2" class="wp-synhighlighter-title" href="#codesyntax_2"  onClick="javascript:wpsh_toggleBlock(2)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_2" onClick="javascript:wpsh_code(2)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_print(2)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_about(2)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_2" class="wp-synhighlighter-inner" style="display: block;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'googl'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://blog.ipalaus.es'</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$short_url</span> <span style="color: #339933;">=</span> googl_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>Puedes pasar un segundo parámetro TRUE/FALSE para que devuelve la URL original si alguna cosa va mal. Por defecto será <em>TRUE</em> (por defecto devolverá la url original si algo falla):</p>
<div id="wpshdo_3" class="wp-synhighlighter-outer"><div id="wpshdt_3" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_3"></a><a id="wpshat_3" class="wp-synhighlighter-title" href="#codesyntax_3"  onClick="javascript:wpsh_toggleBlock(3)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_3" onClick="javascript:wpsh_code(3)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_print(3)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_about(3)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_3" class="wp-synhighlighter-inner" style="display: block;"><span style="color: #000088;">$short_url</span> <span style="color: #339933;">=</span> googl_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ipalaus.es/codeigniter-goo-gl-helper/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CodeIgniter: alojar un array en la URI</title>
		<link>http://blog.ipalaus.es/codeigniter-alojar-un-array-en-la-uri</link>
		<comments>http://blog.ipalaus.es/codeigniter-alojar-un-array-en-la-uri#comments</comments>
		<pubDate>Tue, 06 Apr 2010 02:03:01 +0000</pubDate>
		<dc:creator>Isern Palaus</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[associative]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[uri]]></category>

		<guid isPermaLink="false">http://blog.ipalaus.es/?p=57</guid>
		<description><![CDATA[Mucha gente se pregunta como alojar varios parámetros en la URI, quizá para poder hacer buscas personalizadas y almacenar esos datos en la URI de nuestra aplicación para poder ser reproducida.
Hay una forma muy sencilla con la clase URI de CodeIgniter que nos permite convertir los segmentos de la URI en un array asociativo de <a href="http://blog.ipalaus.es/codeigniter-alojar-un-array-en-la-uri" class="more-link">Más &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Mucha gente se pregunta como alojar varios parámetros en la URI, quizá para poder hacer buscas personalizadas y almacenar esos datos en la URI de nuestra aplicación para poder ser reproducida.</p>
<p>Hay una forma muy sencilla con la clase <strong>URI</strong> de CodeIgniter que nos permite convertir los segmentos de la URI en un array asociativo de clave/valor: <strong>$this-&gt;uri-&gt;uri_to_assoc();</strong>.</p>
<p>Teniendo, por ejemplo, una ruta que sea:</p>
<blockquote><p>dominio.tld/buscar/categoria/zapatos/medida/m/marca/converse/x/y</p></blockquote>
<p>Podemos usar:</p>
<div id="wpshdo_4" class="wp-synhighlighter-outer"><div id="wpshdt_4" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_4"></a><a id="wpshat_4" class="wp-synhighlighter-title" href="#codesyntax_4"  onClick="javascript:wpsh_toggleBlock(4)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_4" onClick="javascript:wpsh_code(4)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_4" onClick="javascript:wpsh_print(4)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_4" onClick="javascript:wpsh_about(4)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_4" class="wp-synhighlighter-inner" style="display: block;"><span style="color: #000088;">$valores</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">uri</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">uri_to_assoc</span><span style="color: #009900;">&#40;</span>1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>Y obtendremos un array:</p>
<div id="wpshdo_5" class="wp-synhighlighter-outer"><div id="wpshdt_5" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_5"></a><a id="wpshat_5" class="wp-synhighlighter-title" href="#codesyntax_5"  onClick="javascript:wpsh_toggleBlock(5)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_5" onClick="javascript:wpsh_code(5)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_5" onClick="javascript:wpsh_print(5)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_5" onClick="javascript:wpsh_about(5)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_5" class="wp-synhighlighter-inner" style="display: block;">[array]<br />
(<br />
&nbsp; &nbsp; 'categoria' =&gt; 'zapatos'<br />
&nbsp; &nbsp; 'medida' =&gt; 'm'<br />
&nbsp; &nbsp; 'marca' =&gt; 'converse'<br />
&nbsp; &nbsp; 'x' =&gt; 'y'<br />
)</div></div>
<p>Si quisiéramos convertir un array a una URI asociativa simplemente llamaríamos <strong>$this-&gt;uri-&gt;uri_to_assoc(<em>array()</em>);</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ipalaus.es/codeigniter-alojar-un-array-en-la-uri/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery plugin: TipTip, tooltips personalizadas</title>
		<link>http://blog.ipalaus.es/jquery-plugin-tiptip-tooltips-personalizadas</link>
		<comments>http://blog.ipalaus.es/jquery-plugin-tiptip-tooltips-personalizadas#comments</comments>
		<pubDate>Mon, 22 Mar 2010 00:44:35 +0000</pubDate>
		<dc:creator>Isern Palaus</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[tooltip]]></category>

		<guid isPermaLink="false">http://blog.ipalaus.es/?p=51</guid>
		<description><![CDATA[ TipTip es una manera sencilla de crear tips cross-browser que además destaca por no hacer uso ninguno de imágenes y perfectamente adaptado para ser personalizado vía CSS. Se ajusta automáticamente a las medidas de nuestro navegador mostrando siempre bien el Tip (en caso de que modifiquemos el tamaño de la ventana, no dejará de <a href="http://blog.ipalaus.es/jquery-plugin-tiptip-tooltips-personalizadas" class="more-link">Más &#62;</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.ipalaus.es/wp-content/uploads/2010/03/jquery-tiptip.png"><img class="alignleft size-medium wp-image-52" title="jQuery plugin: TipTip" src="http://blog.ipalaus.es/wp-content/uploads/2010/03/jquery-tiptip-300x125.png" alt="" width="300" height="125" /></a><strong> TipTip</strong> es una manera sencilla de crear tips cross-browser que además destaca por no hacer uso ninguno de imágenes y perfectamente adaptado para ser personalizado vía CSS. Se ajusta automáticamente a las medidas de nuestro navegador mostrando siempre bien el Tip (en caso de que modifiquemos el tamaño de la ventana, no dejará de mostrase).</p>
<p>Su configuración es más bien sencilla, como la gran mayoría de estos plugins teniendo varias opciones de personalización y de <em>callbacks</em>:</p>
<div id="wpshdo_6" class="wp-synhighlighter-outer"><div id="wpshdt_6" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_6"></a><a id="wpshat_6" class="wp-synhighlighter-title" href="#codesyntax_6"  onClick="javascript:wpsh_toggleBlock(6)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_6" onClick="javascript:wpsh_code(6)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_6" onClick="javascript:wpsh_print(6)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_6" onClick="javascript:wpsh_about(6)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_6" class="wp-synhighlighter-inner" style="display: block;">$<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><br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.ejemplo&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">tipTip</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<div id="wpshdo_7" class="wp-synhighlighter-outer"><div id="wpshdt_7" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_7"></a><a id="wpshat_7" class="wp-synhighlighter-title" href="#codesyntax_7"  onClick="javascript:wpsh_toggleBlock(7)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_7" onClick="javascript:wpsh_code(7)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_7" onClick="javascript:wpsh_print(7)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_7" onClick="javascript:wpsh_about(7)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_7" class="wp-synhighlighter-inner" style="display: block;"><span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://blog.ipalaus.es&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ejemplo&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Blog personal de Isern Palaus&quot;</span>&gt;</span>Isern Palaus<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span></div></div>
<p><span id="more-51"></span></p>
<p>En el siguiente vídeo en inglés, y del creador del plugin para jQuery, podemos ver varios ejemplos de su uso:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="338" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=8508658&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=c9ff23&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="600" height="338" src="http://vimeo.com/moogaloop.swf?clip_id=8508658&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=c9ff23&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Descargar | <a href="http://blog.ipalaus.es/dm.php?id=7">tipTipv12.zip</a><br />
Página oficial | <a href="http://code.drewwilson.com/entry/tiptip-jquery-plugin">TipTip jQuery Plugin</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ipalaus.es/jquery-plugin-tiptip-tooltips-personalizadas/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Plugin: js-columns columnas al estilo periódico</title>
		<link>http://blog.ipalaus.es/jquery-plugin-js-column-columnas-al-estilo-periodico</link>
		<comments>http://blog.ipalaus.es/jquery-plugin-js-column-columnas-al-estilo-periodico#comments</comments>
		<pubDate>Sat, 20 Mar 2010 16:46:49 +0000</pubDate>
		<dc:creator>Isern Palaus</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[columns]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[text]]></category>

		<guid isPermaLink="false">http://blog.ipalaus.es/?p=45</guid>
		<description><![CDATA[js-columns es un plugin para jQuery que nos permite crear columnas al estilo de un periódico fácilmente. Mientras esperamos la total integración de CSS3 que nos permitirá hacerlo directamente desde nuestra hoja de estilos, esta es una buena opción.
Aún está un poco verde en su primera versión (31/01/2010) nos permite mostrar columnas dentro de un contenedor <a href="http://blog.ipalaus.es/jquery-plugin-js-column-columnas-al-estilo-periodico" class="more-link">Más &#62;</a>]]></description>
			<content:encoded><![CDATA[<p><strong><a href="http://blog.ipalaus.es/wp-content/uploads/2010/03/jquer-plugin-columnas.png"><img class="alignright size-medium wp-image-46" title="jQuery Plugin: js-columns" src="http://blog.ipalaus.es/wp-content/uploads/2010/03/jquer-plugin-columnas-300x147.png" alt="" width="300" height="147" /></a>js-columns</strong> es un plugin para jQuery que nos permite crear columnas al estilo de un periódico fácilmente. Mientras esperamos la total integración de CSS3 que nos permitirá hacerlo directamente desde nuestra hoja de estilos, esta es una buena opción.</p>
<p>Aún está un poco verde en su primera versión (31/01/2010) nos permite mostrar columnas dentro de un contenedor (es decir, div) y crea una paginación en caso de que el contenido sea más grande que el contenedor, y el mismo nos permite movernos en él sin tener que actualizar la página. También se adapta a la resolución de nuestro navegador en caso de que modifiquemos el tamaño de la ventana, creando el paginador de nuevo si hiciera falta. A parte, nos deja añadir imágenes fácilmente y nos cuadra la misma con las columnas creadas.</p>
<p>En el mismo rar nos viene una página de ejemplo, pero para crear un div con columnas lo haremos así:</p>
<div id="wpshdo_8" class="wp-synhighlighter-outer"><div id="wpshdt_8" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_8"></a><a id="wpshat_8" class="wp-synhighlighter-title" href="#codesyntax_8"  onClick="javascript:wpsh_toggleBlock(8)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_8" onClick="javascript:wpsh_code(8)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_8" onClick="javascript:wpsh_print(8)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_8" onClick="javascript:wpsh_about(8)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_8" class="wp-synhighlighter-inner" style="display: block;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.columna'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">columns</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>paging<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>Descargar | <a href="http://blog.ipalaus.es/dm.php?id=6">js-columns-0.1.zip</a><br />Página oficial | <a href="http://code.google.com/p/js-columns/w/list">js-columns</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ipalaus.es/jquery-plugin-js-column-columnas-al-estilo-periodico/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AJAX Login con jQuery y CodeIgniter &#8211; v2 + archivos</title>
		<link>http://blog.ipalaus.es/ajax-login-con-jquery-y-codeigniter-v2-archivos</link>
		<comments>http://blog.ipalaus.es/ajax-login-con-jquery-y-codeigniter-v2-archivos#comments</comments>
		<pubDate>Tue, 01 Dec 2009 21:29:21 +0000</pubDate>
		<dc:creator>Isern Palaus</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ajax login]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[login]]></category>

		<guid isPermaLink="false">http://blog.ipalaus.es/?p=18</guid>
		<description><![CDATA[Hola amigos,
Esta es la revisión del tutorial que escribí hace más de un año. Es prácticamente lo mismo pero con todos los archivos que necesitas en un zip, a parte de ciertas modificaciones necesarias en el procesado de los datos.
Para esa gente que esta buscando un sistema de usuarios funcional con registro, tengo que decir que no <a href="http://blog.ipalaus.es/ajax-login-con-jquery-y-codeigniter-v2-archivos" class="more-link">Más &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Hola amigos,</p>
<p>Esta es la revisión del tutorial que escribí hace más de un año. Es prácticamente lo mismo pero con todos los archivos que necesitas en un zip, a parte de ciertas modificaciones necesarias en el procesado de los datos.</p>
<p>Para esa gente que esta buscando un sistema de usuarios funcional con registro, tengo que decir que no tengo tiempo para programarlo todo por mi mismo para este manual. De este modo, como he hecho desde que comencé en CodeIgniter, usaremos una aplicación de terceros: un sistema completo de usuarios. Lo he basado en el trabajo de Popcorn, llamado &#8216;Redux Authentication&#8217; (v2 beta).<br />
Lo primero que necesitamos es descargar la librería de Redux. Accedemos al proyecto en Google Code y lo descargamos <a href="http://code.google.com/p/reduxauth/" target="_self">aquí</a>. Puedes ir a la <a href="http://codeigniter.com/forums/viewthread/90254/">entrada oficial</a> en el foro de CodeIgniter para preguntar sobre la misma.<br />
Cuando descargues la librería, verás que dentro existe una carpeta llamada &#8216;Example Application&#8217;. Usaremos esta aplicación pero necesitamos actualizarla a la ultima versión de CodeIgniter, sino no nos funcionará. Ten en cuenta, que en el pack final ya esta actualizado pero es mucho mejor si lo haces por tu propio pie, aprenderás más.<br />
Es muy fácil actualizarlo: descargas <a href="http://www.codeigniter.com/">CodeIgniter</a> y lo descomprimes. Ve a &#8216;Example Application&#8217;, renombra la carpeta a ajaxlogin (usaré este nombre en los ejemplos). Entra en la misma y seguidamente a /system. Borra <strong>todas</strong> las carpetas excepto <strong>application</strong>, donde esta la aplicación. Accede a la versión descarga de CodeIgniter y copia todas las carpetas que has eliminado (todas menos application). Puedes encontrar la guía oficial de CodeIgniter para la actualización <a href="http://codeigniter.com/user_guide/installation/upgrading.html">aquí</a>.<br />
Entonces, instala la base de datos y configurala. Lo primero que tienes que hacer es añadir un grupo llamado &#8216;members&#8217; en la tabla de grupos:</p>
<div id="wpshdo_9" class="wp-synhighlighter-outer"><div id="wpshdt_9" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_9"></a><a id="wpshat_9" class="wp-synhighlighter-title" href="#codesyntax_9"  onClick="javascript:wpsh_toggleBlock(9)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_9" onClick="javascript:wpsh_code(9)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_9" onClick="javascript:wpsh_print(9)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_9" onClick="javascript:wpsh_about(9)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_9" class="wp-synhighlighter-inner" style="display: block;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> groups <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`id`</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">`name`</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">`description`</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'member'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'Members'</span><span style="color: #66cc66;">&#41;</span></div></div>
<p><span id="more-18"></span><br />
En el archivo config/redux_auth.php verás que hay una opción para configurar el grupo por defecto. En la base de datos no tenemos datos de modo que necesitamos añadir un grupo por defecto y modificar el archivo de configuración para que lo detecte. Otra recomendación para este mismo archivo es cambiar la configuración de activación a FALSE porque no funciona del todo. Hay otras variables que puedes cambiar, como el método de entrada (username, email&#8230;). He elegido el e-mail, que es el que viene por defecto.  Cambiar para que sea el usuario no es difícil. Probarlo.<br />
<div id="wpshdo_10" class="wp-synhighlighter-outer"><div id="wpshdt_10" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_10"></a><a id="wpshat_10" class="wp-synhighlighter-title" href="#codesyntax_10"  onClick="javascript:wpsh_toggleBlock(10)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_10" onClick="javascript:wpsh_code(10)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_10" onClick="javascript:wpsh_print(10)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_10" onClick="javascript:wpsh_about(10)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_10" class="wp-synhighlighter-inner" style="display: block;"><span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'email_activation'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span></div></div><br />
Ahora puedes ir a tu página, configurar otras cosas que harías en cualquier aplicación&#8230;<br />
Lo primero que haremos será crear un usuario. Esto lo tienes que hacer desde la página, claro. Accede y lo verás claro. Después, intenta acceder. Serás redirigido al apartado status y verás <strong>bool(true)</strong> si has entrado correctamente. ¡Ahora es hora de programar nuestra aplicación en AJAX!<br />
Ve a <strong>/system/application/views/template.php</strong> y, entre  y  añade la <a href="http://www.jquery.com/">librería de jQuery que has descargado</a>:</p>
<div id="wpshdo_11" class="wp-synhighlighter-outer"><div id="wpshdt_11" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_11"></a><a id="wpshat_11" class="wp-synhighlighter-title" href="#codesyntax_11"  onClick="javascript:wpsh_toggleBlock(11)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_11" onClick="javascript:wpsh_code(11)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_11" onClick="javascript:wpsh_print(11)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_11" onClick="javascript:wpsh_about(11)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_11" class="wp-synhighlighter-inner" style="display: block;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&lt;?php echo base_url().'assets/js/jquery-1.3.2.min.js'; ?&gt;&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=&lt;?</span>php echo base_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #3366CC;">'assets/js/ajaxlogin.js'</span><span style="color: #339933;">;</span> <span style="color: #339933;">?&gt;</span><span style="color: #3366CC;">&quot;&gt;&lt;/script&gt;</span></div></div>
<p>En este caso, la diferencia con el otro script, es que usaremos la función de Redux para el login y esto optimizará nuestro código ya que esta mucho más depurado. En el controller welcome añadiremos dos funciones:</p>
<div id="wpshdo_12" class="wp-synhighlighter-outer"><div id="wpshdt_12" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_12"></a><a id="wpshat_12" class="wp-synhighlighter-title" href="#codesyntax_12"  onClick="javascript:wpsh_toggleBlock(12)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_12" onClick="javascript:wpsh_code(12)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_12" onClick="javascript:wpsh_print(12)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_12" onClick="javascript:wpsh_about(12)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_12" class="wp-synhighlighter-inner" style="display: block;"><span style="color: #000000; font-weight: bold;">function</span> _check_login<span style="color: #009900;">&#40;</span><span style="color: #000088;">$email</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redux_auth</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">login</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$email</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">password</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> ajaxLogin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'validation'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">password</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loginemail</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_rules</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'email'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Email Address'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'trim|required|callback__check_login'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_rules</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'password'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Password'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'trim|required'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">run</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>    <span style="color: #0000ff;">'success'</span> <span style="color: #339933;">=&gt;</span>    <span style="color: #0000ff;">'no'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'message'</span> <span style="color: #339933;">=&gt;</span>    <span style="color: #0000ff;">'The email or password you provided are wrong.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/json_encode"><span style="color: #990000;">json_encode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>    <span style="color: #0000ff;">'success'</span> <span style="color: #339933;">=&gt;</span>    <span style="color: #0000ff;">'yes'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'welcome'</span> <span style="color: #339933;">=&gt;</span>    <span style="color: #0000ff;">'Welcome '</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loginemail</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/json_encode"><span style="color: #990000;">json_encode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$output</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$output</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Para entender el código: la primera función, _check_login(), usa el modelo redux_auth_model.php para validar el correo y la contraseña que hemos seleccionado. Para más información mira el modelo en la carpeta models. Si la información procesada es correcta devuelve TRUE, sino FALSE. En caso de que devuelva TRUE, la aplicación crea la sesión con nuestro e-mail. Si necesitas alguna cosa más, edita el modelo.</p>
<p>La segunda función es un mix de la función de login de Redux y mi función de AJAX. Toma los dos inputs y los valida. El primero, correo electrónico, usa la función callback a la función _check_login(). Si la información no es correcta, o sucede algún problema, devuelve FALSE. Entonces pasaremos la información a la función AJAX y la codificaremos con JSON. La información codificada se muestra tal que así: { &#8220;success&#8221;: &#8220;no&#8221;, &#8220;message&#8221;: &#8220;The email or password you provided are wrong.&#8221; }.</p>
<p>Hay que tener en cuenta que uso $this-&gt;password y $this-&gt;loginemail. Estas variables tienen que ser definidas en el inicio el controlador, así:</p>
<div id="wpshdo_13" class="wp-synhighlighter-outer"><div id="wpshdt_13" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_13"></a><a id="wpshat_13" class="wp-synhighlighter-title" href="#codesyntax_13"  onClick="javascript:wpsh_toggleBlock(13)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_13" onClick="javascript:wpsh_code(13)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_13" onClick="javascript:wpsh_print(13)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_13" onClick="javascript:wpsh_about(13)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_13" class="wp-synhighlighter-inner" style="display: block;"><span style="color: #000000; font-weight: bold;">class</span> Welcome <span style="color: #000000; font-weight: bold;">extends</span> Controller <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$password</span>     <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$loginemail</span>    <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* index<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* @return void<br />
&nbsp; &nbsp; &nbsp;* @author Mathew<br />
&nbsp; &nbsp; **/</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; redirect<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'welcome/status'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #339933;">...</span></div></div>
<p>Perfecto! Ahora modificaremos el login. Como sabes, la mejor manera de crear un formulario en CodeIgniter es accediendo a su user guide. De este modo, abre<strong> /views/login.php</strong>. Cuando tenemos un tenemos un formulario de login normalmente solo lo mostramos cuando el usuario no esta identificado. En el ejemplo de la librería Redux esto no pasa y tenemos que modificarlo. La manera es comprobar si existe el item &#8216;identity&#8217; en la session. Añade al principio del archivo:</p>
<div id="wpshdo_14" class="wp-synhighlighter-outer"><div id="wpshdt_14" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_14"></a><a id="wpshat_14" class="wp-synhighlighter-title" href="#codesyntax_14"  onClick="javascript:wpsh_toggleBlock(14)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_14" onClick="javascript:wpsh_code(14)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_14" onClick="javascript:wpsh_print(14)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_14" onClick="javascript:wpsh_about(14)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_14" class="wp-synhighlighter-inner" style="display: block;"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">userdata</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'identity'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;h1&gt;You're aready logged in!&lt;/h1&gt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;h1&gt;Login&lt;/h1&gt;</div></div>
<p>Esto comprobará si existe. Al final del archivo, añade:</p>
<div id="wpshdo_15" class="wp-synhighlighter-outer"><div id="wpshdt_15" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_15"></a><a id="wpshat_15" class="wp-synhighlighter-title" href="#codesyntax_15"  onClick="javascript:wpsh_toggleBlock(15)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_15" onClick="javascript:wpsh_code(15)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_15" onClick="javascript:wpsh_print(15)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_15" onClick="javascript:wpsh_about(15)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_15" class="wp-synhighlighter-inner" style="display: block;"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
<p>Compruébalo. Accede y vuelve al formulario de identificación. Mostrará <strong>You&#8217;re already logged in</strong>.<br />
Tenemos que añadir algunas lineas más al archivo login.php. Cambia el <strong>form_open()</strong> y añade un id, añade un id a la tabla y añade un id a las divs extras que usaremos para mostrar los errores o sucesos de la aplicación AJAX. Es necesario que jQuery los identifique y eso lo hacemos con los ids.</p>
<div id="wpshdo_16" class="wp-synhighlighter-outer"><div id="wpshdt_16" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_16"></a><a id="wpshat_16" class="wp-synhighlighter-title" href="#codesyntax_16"  onClick="javascript:wpsh_toggleBlock(16)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_16" onClick="javascript:wpsh_code(16)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_16" onClick="javascript:wpsh_print(16)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_16" onClick="javascript:wpsh_about(16)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_16" class="wp-synhighlighter-inner" style="display: block;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> form_open<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'welcome/login'</span><span style="color: #339933;">,</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'userlogin'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
<br />
&lt;table id=&quot;loginform&quot;&gt;<br />
<br />
&lt;div id=&quot;logged&quot;&gt;&lt;div&gt;<br />
<br />
&lt;div id=&quot;loginerror&quot;&gt;&lt;/div&gt;</div></div>
<p>He añadido estas dos últimas &lt;div&gt;&#8217; despues del <strong>form_close()</strong>.</p>
<p>A parte, haz estos cambios:<br />
<div id="wpshdo_17" class="wp-synhighlighter-outer"><div id="wpshdt_17" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_17"></a><a id="wpshat_17" class="wp-synhighlighter-title" href="#codesyntax_17"  onClick="javascript:wpsh_toggleBlock(17)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_17" onClick="javascript:wpsh_code(17)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_17" onClick="javascript:wpsh_print(17)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_17" onClick="javascript:wpsh_about(17)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_17" class="wp-synhighlighter-inner" style="display: block;">&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> form_input<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'email'</span><span style="color: #339933;">,</span> set_value<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;</div></div></p>
<p>Por:</p>
<div id="wpshdo_18" class="wp-synhighlighter-outer"><div id="wpshdt_18" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_18"></a><a id="wpshat_18" class="wp-synhighlighter-title" href="#codesyntax_18"  onClick="javascript:wpsh_toggleBlock(18)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_18" onClick="javascript:wpsh_code(18)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_18" onClick="javascript:wpsh_print(18)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_18" onClick="javascript:wpsh_about(18)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_18" class="wp-synhighlighter-inner" style="display: block;">&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;email&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> set_value<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; id=&quot;email&quot; /&gt;&lt;/td&gt;</div></div>
<p>Y:</p>
<div id="wpshdo_19" class="wp-synhighlighter-outer"><div id="wpshdt_19" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_19"></a><a id="wpshat_19" class="wp-synhighlighter-title" href="#codesyntax_19"  onClick="javascript:wpsh_toggleBlock(19)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_19" onClick="javascript:wpsh_code(19)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_19" onClick="javascript:wpsh_print(19)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_19" onClick="javascript:wpsh_about(19)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_19" class="wp-synhighlighter-inner" style="display: block;">&lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> form_password<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;</div></div>
<p>Por:</p>
<div id="wpshdo_20" class="wp-synhighlighter-outer"><div id="wpshdt_20" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_20"></a><a id="wpshat_20" class="wp-synhighlighter-title" href="#codesyntax_20"  onClick="javascript:wpsh_toggleBlock(20)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_20" onClick="javascript:wpsh_code(20)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_20" onClick="javascript:wpsh_print(20)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_20" onClick="javascript:wpsh_about(20)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_20" class="wp-synhighlighter-inner" style="display: block;"><span style="color: #339933;">&lt;</span>td<span style="color: #339933;">&gt;&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;password&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;password&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span> id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;password&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>td<span style="color: #339933;">&gt;</span></div></div>
<p>Ahora es tiempo del archivo javascript. Recuerda que antes hemos añadido la librería de jQuery. Crea un archivo que se llame <strong>ajaxlogin.js</strong> en <strong>/assets/js/</strong>. Para usar el ajaxForm necesitas un plugin. Lo puedes descargar <a href="http://www.malsup.com/jquery/form/#download">aquí</a>. Lo añadimos igual que hemos hecho los dos del principio, en <strong>/views/template.php</strong>:</p>
<div id="wpshdo_21" class="wp-synhighlighter-outer"><div id="wpshdt_21" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_21"></a><a id="wpshat_21" class="wp-synhighlighter-title" href="#codesyntax_21"  onClick="javascript:wpsh_toggleBlock(21)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_21" onClick="javascript:wpsh_code(21)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_21" onClick="javascript:wpsh_print(21)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_21" onClick="javascript:wpsh_about(21)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_21" class="wp-synhighlighter-inner" style="display: block;">&lt;script type=&quot;text/javascript&quot; src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> base_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'assets/js/jquery.form.js'</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;&lt;/script&gt;</div></div>
<p>Ahora, escribe en <strong>ajaxlogin.js</strong>:</p>
<div id="wpshdo_22" class="wp-synhighlighter-outer"><div id="wpshdt_22" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_22"></a><a id="wpshat_22" class="wp-synhighlighter-title" href="#codesyntax_22"  onClick="javascript:wpsh_toggleBlock(22)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_22" onClick="javascript:wpsh_code(22)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_22" onClick="javascript:wpsh_print(22)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_22" onClick="javascript:wpsh_about(22)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_22" class="wp-synhighlighter-inner" style="display: block;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>ready<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;#userlogin&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>ajaxForm<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; type<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;POST&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;http://localhost/ajaxlogin/index.php/welcome/ajaxLogin&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dataType<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;json&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; data<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;email=&quot;</span><span style="color: #339933;">+</span>$<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;#email&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>val<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;&amp;amp;password;=&quot;</span><span style="color: #339933;">+</span>$<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;#password&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>val<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; success<span style="color: #339933;">:</span> updateLogin<br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<div id="_mcePaste">Ten en cuenta que es posible que tengas que cambiar la URL.  Yo lo uso en mi localhost y con el alias ajaxlogin. Mismamente, uso el index.php y el controlador welcome. Debes modificarlo si es necesario.</div>
<div id="_mcePaste">Ahora mismo, el script funcionaria pero debemos añadirle un complemento&#8230; la función que llama ajaxForm cuando se ejecuta:</div>
<p>Ten en cuenta que es posible que tengas que cambiar la URL.  Yo lo uso en mi localhost y con el alias ajaxlogin. Mismamente, uso el index.php y el controlador welcome. Debes modificarlo si es necesario.<br />
Ahora mismo, el script funcionaria pero debemos añadirle un complemento&#8230; la función que llama ajaxForm cuando se ejecuta:</p>
<div id="wpshdo_23" class="wp-synhighlighter-outer"><div id="wpshdt_23" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_23"></a><a id="wpshat_23" class="wp-synhighlighter-title" href="#codesyntax_23"  onClick="javascript:wpsh_toggleBlock(23)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_23" onClick="javascript:wpsh_code(23)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_23" onClick="javascript:wpsh_print(23)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_23" onClick="javascript:wpsh_about(23)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_23" class="wp-synhighlighter-inner" style="display: block;"><span style="color: #000000; font-weight: bold;">function</span> updateLogin<span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#logged'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>html<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#logged'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>hide<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;#loginform&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>fadeOut<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;slow&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>data<span style="color: #339933;">.</span>success <span style="color: #339933;">==</span> <span style="color: #0000ff;">'yes'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#logged'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>html<span style="color: #009900;">&#40;</span>data<span style="color: #339933;">.</span>welcome<span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>fadeIn<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;slow&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>data<span style="color: #339933;">.</span>success <span style="color: #339933;">==</span> <span style="color: #0000ff;">'no'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#loginerror'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>html<span style="color: #009900;">&#40;</span>data<span style="color: #339933;">.</span>message<span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>fadeIn<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;slow&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>fadeOut<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;slow&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;#loginform&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>fadeIn<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;slow&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Esto creará nuestra animación y hará desaparecer el form. Igualmente escribirá los datos JSON a la &lt;div&gt; que hemos especificado.</p>
<p><strong>Puedes descargar los archivos de este ejemplo funcionando aquí: <a href="http://blog.ipalaus.es/dm.php?id=4">ipalaus-ajaxlogin-v0.2.rar</a></strong>.</p>
<p>¡Gracias a todos! ¡Espero que funcione!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ipalaus.es/ajax-login-con-jquery-y-codeigniter-v2-archivos/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>wpToGo, la aplicaci&#243;n m&#243;vil para Wordpress y Android</title>
		<link>http://blog.ipalaus.es/wptogo-la-aplicacin-mvil-para-wordpress-y-android</link>
		<comments>http://blog.ipalaus.es/wptogo-la-aplicacin-mvil-para-wordpress-y-android#comments</comments>
		<pubDate>Sat, 21 Nov 2009 13:49:10 +0000</pubDate>
		<dc:creator>Isern Palaus</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[wptogo]]></category>

		<guid isPermaLink="false">http://blog.ipalaus.es/wptogo-la-aplicacin-mvil-para-wordpress-y-android</guid>
		<description><![CDATA[Hola amigos,
Estoy provando la aplicaci&#243;n wpToGo para m&#243;viles con el sistema operativo Android. La verdad, me parece una gran aplicaci&#243;n y seguramente la usar&#233; para un nuevo proyecto. Me gustaria poder modificarla o adaptar una aplicaci&#243;n en PHP que trabajara con la misma, pero seria necesario adaptarse a este sistema&#8230; ya que mi pr&#243;ximo proyecto <a href="http://blog.ipalaus.es/wptogo-la-aplicacin-mvil-para-wordpress-y-android" class="more-link">Más &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Hola amigos,</p>
<p>Estoy provando la aplicaci&oacute;n wpToGo para m&oacute;viles con el sistema operativo Android. La verdad, me parece una gran aplicaci&oacute;n y seguramente la usar&eacute; para un nuevo proyecto. Me gustaria poder modificarla o adaptar una aplicaci&oacute;n en PHP que trabajara con la misma, pero seria necesario adaptarse a este sistema&#8230; ya que mi pr&oacute;ximo proyecto lo escribir&eacute; integramente des del m&oacute;vil.</p>
<p>Hasta pronto!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ipalaus.es/wptogo-la-aplicacin-mvil-para-wordpress-y-android/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CodeIgniter: HTML Helper modificado. script_tag(&#8220;archivo.js&#8221;); añadido.</title>
		<link>http://blog.ipalaus.es/codeigniter-html-helper-modificado-anade-javascript-facilmente</link>
		<comments>http://blog.ipalaus.es/codeigniter-html-helper-modificado-anade-javascript-facilmente#comments</comments>
		<pubDate>Fri, 20 Jun 2008 21:52:34 +0000</pubDate>
		<dc:creator>Isern Palaus</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[helpers]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://blog.ipalaus.es/?p=14</guid>
		<description><![CDATA[Hola,
Después de mucho tiempo sin escribir, y habiendo salido ya la versión 1.6.2 de CodeIgniter, escribo para presentar una mejora a un helper de CodeIgniter. Concretamente se trata del HTML Helper, el cual incluye funcione para la ayuda en el HTML.
¿Qué hace? ¿Por qué? La última versión del framework añadía la posibilidad de crear tags <a href="http://blog.ipalaus.es/codeigniter-html-helper-modificado-anade-javascript-facilmente" class="more-link">Más &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Hola,</p>
<p>Después de mucho tiempo sin escribir, y habiendo salido ya la versión 1.6.2 de <a href="http://www.codeigniter.com">CodeIgniter</a>, escribo para presentar una mejora a un <em>helper</em> de <a href="http://www.codeigniter.com">CodeIgniter</a>. Concretamente se trata del <a href="http://codeigniter.com/user_guide/helpers/html_helper.html">HTML Helper</a>, el cual incluye funcione para la ayuda en el HTML.</p>
<p>¿Qué hace? ¿Por qué? La última versión del <em>framework</em> añadía la posibilidad de crear tags <strong>&lt;link /&gt;</strong> con lo que podíamos añadir facilmente archivos <strong>CSS</strong>, <strong>shorcuts.ico</strong> u otros similares. Esto se hace mediante:</p>
<div id="wpshdo_24" class="wp-synhighlighter-outer"><div id="wpshdt_24" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_24"></a><a id="wpshat_24" class="wp-synhighlighter-title" href="#codesyntax_24"  onClick="javascript:wpsh_toggleBlock(24)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_24" onClick="javascript:wpsh_code(24)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_24" onClick="javascript:wpsh_print(24)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_24" onClick="javascript:wpsh_about(24)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_24" class="wp-synhighlighter-inner" style="display: block;">link_tag<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'archivo.css);</span></div></div>
<p>Y&#8230; ¿porqué no para incluir archivos JavaScript? Así que me decidí a hacer mi primer aportación al <em>core</em> de <a href="http://www.codeigniter.com">CodeIgniter</a> (y espero que la añadan, claro). Esto consiste en la función <strong>script_tag();</strong> para añadir tags <strong>&lt;script /&gt;</strong>.</p>
<p>Y&#8230; ¿Cómo se usa? Simplemente es una extensión del <em>helper</em> existente así que debemos colocar el archivo dentro de la carpeta <strong>helpers</strong> dentro de <strong>application</strong> con el nombre <strong>MY_html_helper.php</strong> teniendo en cuenta que el prefijo para las extensiones es &#8220;MY_&#8221; ($config['subclass_prefix'] = &#8216;MY_&#8217;; en config.php).</p>
<p>El código en cuestión es el siguiente:<br />
<div id="wpshdo_25" class="wp-synhighlighter-outer"><div id="wpshdt_25" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_25"></a><a id="wpshat_25" class="wp-synhighlighter-title" href="#codesyntax_25"  onClick="javascript:wpsh_toggleBlock(25)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_25" onClick="javascript:wpsh_code(25)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_25" onClick="javascript:wpsh_print(25)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_25" onClick="javascript:wpsh_about(25)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_25" class="wp-synhighlighter-inner" style="display: block;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> &nbsp;<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <a href="http://www.php.net/defined"><span style="color: #990000;">defined</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'BASEPATH'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'No direct script access allowed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #009933; font-style: italic;">/**<br />
* Script<br />
*<br />
* Generates a script inclusion of a JavaScript file<br />
* Based on the CodeIgniters original Link Tag.<br />
*<br />
* Author(s): Isern Palaus &lt;ipalaus@ipalaus.es&gt;, Viktor Rutberg &lt;wishie@gmail.com&gt;<br />
*<br />
* @access &nbsp; &nbsp;public<br />
* @param &nbsp; &nbsp;mixed &nbsp; &nbsp;javascript sources or an array<br />
* @param &nbsp; &nbsp;string &nbsp; &nbsp;language<br />
* @param &nbsp; &nbsp;string &nbsp; &nbsp;type<br />
* @param &nbsp; &nbsp;boolean &nbsp; &nbsp;should index_page be added to the javascript path<br />
* @return &nbsp; &nbsp;string<br />
*/</span> &nbsp; &nbsp;<br />
<br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'script_tag'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> script_tag<span style="color: #009900;">&#40;</span><span style="color: #000088;">$src</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$language</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'javascript'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$type</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'text/javascript'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$index_page</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$CI</span> <span style="color: #339933;">=&amp;</span> get_instance<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$script</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;script '</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_array"><span style="color: #990000;">is_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$src</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$src</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$k</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'src'</span> AND <a href="http://www.php.net/strpos"><span style="color: #990000;">strpos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'://'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$index_page</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$script</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' src=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$CI</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">site_url</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$script</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' src=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$CI</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">slash_item</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'base_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000088;">$v</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$script</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$k</span>=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$v</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$script</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/strpos"><span style="color: #990000;">strpos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$src</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'://'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$script</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' src=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$src</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; '</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$index_page</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$script</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' src=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$CI</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">site_url</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$src</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; '</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$script</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' src=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$CI</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">slash_item</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'base_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000088;">$src</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; '</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$script</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'language=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$language</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; type=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$type</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;'</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$script</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$script</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;/script&gt;'</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$script</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div></p>
<p>En cuanto su uso es sencillo:<br />
<div id="wpshdo_26" class="wp-synhighlighter-outer"><div id="wpshdt_26" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_26"></a><a id="wpshat_26" class="wp-synhighlighter-title" href="#codesyntax_26"  onClick="javascript:wpsh_toggleBlock(26)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_26" onClick="javascript:wpsh_code(26)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_26" onClick="javascript:wpsh_print(26)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_26" onClick="javascript:wpsh_about(26)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_26" class="wp-synhighlighter-inner" style="display: block;">script_tag<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'archivo.js);</span></div></div></p>
<p>Pronto os presentaré también otra modificación del <em>helper</em> <a href="http://codeigniter.com/user_guide/helpers/url_helper.html">URL Helper</a>. Hasta pronto.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ipalaus.es/codeigniter-html-helper-modificado-anade-javascript-facilmente/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>CodeIgniter: mod_rewrite</title>
		<link>http://blog.ipalaus.es/codeigniter-mod_rewrite</link>
		<comments>http://blog.ipalaus.es/codeigniter-mod_rewrite#comments</comments>
		<pubDate>Sun, 30 Mar 2008 15:17:12 +0000</pubDate>
		<dc:creator>Isern Palaus</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.ipalaus.es/?p=12</guid>
		<description><![CDATA[Uno de los principales inconvenientes de CodeIgniter es, en parte, visual en la dirección URL. Solemos tener nuestros programas con http://localhost/index.php/controlador/funcion y seguramente quedaría mucho mejor algo tipo: http://localhost/controlador/funcion, ¿verdad? Pues bien, para hacer esto necesitaremos usar Apache y el modulo mod_rewrite.
Para empezar será necesario saber si estamos usando mod_rewrite en Apache. Lo más fácil <a href="http://blog.ipalaus.es/codeigniter-mod_rewrite" class="more-link">Más &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Uno de los principales inconvenientes de CodeIgniter es, en parte, visual en la dirección URL. Solemos tener nuestros programas con <em>http://localhost/index.php/controlador/funcion </em>y seguramente quedaría mucho mejor algo tipo: <em>http://localhost/controlador/funcion</em>, ¿verdad? Pues bien, para hacer esto necesitaremos usar <a href="http://www.apache.org">Apache</a> y el modulo <em>mod_rewrite</em>.</p>
<p>Para empezar será necesario saber si estamos usando <em>mod_rewrite</em> en Apache. Lo más fácil es, directamente, ir al archivo de configuración (el archivo <strong>http.conf</strong>) y buscar: mod_rewrite.so. Deberíamos encontrar la siguiente línea:</p>
<p>[code]LoadModule rewrite_module modules/mod_rewrite.so[/code]</p>
<p>Sin embargo, si esta contiene un símbolo de almohadilla (<strong>#</strong>) es que no esta activado. Si lo contiene al principio, lo borramos, guardamos y reiniciamos el servidor. Así, <em>mod_rewrite</em> se iniciará cada vez al iniciar Apache.</p>
<p>Ahora es el momento de crear nuestro archivo de configuración especifico en el directorio donde este nuestro <strong>index.php</strong>. A este archivo le pondremos de nombre <strong>.htaccess</strong> y contendrá lo siguiente:</p>
<div id="wpshdo_27" class="wp-synhighlighter-outer"><div id="wpshdt_27" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_27"></a><a id="wpshat_27" class="wp-synhighlighter-title" href="#codesyntax_27"  onClick="javascript:wpsh_toggleBlock(27)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_27" onClick="javascript:wpsh_code(27)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_27" onClick="javascript:wpsh_print(27)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_27" onClick="javascript:wpsh_about(27)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_27" class="wp-synhighlighter-inner" style="display: block;">RewriteEngine On<br />
RewriteBase /<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteCond %{REQUEST_FILENAME} !-d<br />
RewriteRule ^(.*)$ index.php/$1 [L]<br />
<br />
# If we don't have mod_rewrite installed, all 404's<br />
# can be sent to index.php, and everything works as normal.<br />
# Submitted by: ElliotHaughin<br />
ErrorDocument 404 /index.php</div></div>
<p>Bien, con esto ya nos ocupamos de cuando se acceda a nuestra web automáticamente, lo que hace el servidor web, es catalogar como si accediéramos a la misma pero con <em>index.php/</em> al principio. Solo nos queda una cosa, que <a href="http://www.codeigniter.com">CodeIgniter</a> nos construya los enlaces sin el <strong>index.php/</strong>. De este modo, accedemos al archivo <strong>config.php</strong> y cambiaremos la variable <em>$config['index_page']</em>:<br />
De:<br />
<div id="wpshdo_28" class="wp-synhighlighter-outer"><div id="wpshdt_28" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_28"></a><a id="wpshat_28" class="wp-synhighlighter-title" href="#codesyntax_28"  onClick="javascript:wpsh_toggleBlock(28)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_28" onClick="javascript:wpsh_code(28)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_28" onClick="javascript:wpsh_print(28)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_28" onClick="javascript:wpsh_about(28)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_28" class="wp-synhighlighter-inner" style="display: block;"><span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'index_page'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;index.php&quot;</span><span style="color: #339933;">;</span></div></div></p>
<p>A:<br />
<div id="wpshdo_29" class="wp-synhighlighter-outer"><div id="wpshdt_29" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_29"></a><a id="wpshat_29" class="wp-synhighlighter-title" href="#codesyntax_29"  onClick="javascript:wpsh_toggleBlock(29)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_29" onClick="javascript:wpsh_code(29)" title="Show code only"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_29" onClick="javascript:wpsh_print(29)" title="Print code"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="#codesyntax_29" onClick="javascript:wpsh_about(29)" title="Show plugin information"><img border="0" style="border: 0 none" src="http://blog.ipalaus.es/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_29" class="wp-synhighlighter-inner" style="display: block;"><span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'index_page'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span></div></div><br />
Y esto es todo para tener unas direcciones URL mucho más limpias. Espero que les haya ayudado de nuevo y hasta pronto.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ipalaus.es/codeigniter-mod_rewrite/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Activar $_GET en CodeIgniter</title>
		<link>http://blog.ipalaus.es/activar-get-en-codeigniter</link>
		<comments>http://blog.ipalaus.es/activar-get-en-codeigniter#comments</comments>
		<pubDate>Sun, 30 Mar 2008 14:55:16 +0000</pubDate>
		<dc:creator>Isern Palaus</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[activar]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[get]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.ipalaus.es/?p=11</guid>
		<description><![CDATA[Uno de los inconvenientes que nos encontramos, a veces, al programar en CodeIgniter es que no podemos pasar datos, por ejemplo, con QUERY_STRINGS, que es esa información que sigue después del símbolo ? en nuestra URL. Un ejemplo de este método sería una URL tipo: http://blog.ipalaus.es/?id=3.
Para solucionar este problema deberemos hacer solo dos cosas:

En nuestro <a href="http://blog.ipalaus.es/activar-get-en-codeigniter" class="more-link">Más &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Uno de los inconvenientes que nos encontramos, a veces, al programar en <a href="http://www.codeigniter.com">CodeIgniter</a> es que no podemos pasar datos, por ejemplo, con QUERY_STRINGS, que es esa información que sigue después del símbolo <strong>?</strong> en nuestra URL. Un ejemplo de este método sería una URL tipo: <em>http://blog.ipalaus.es/?id=3</em>.</p>
<p>Para solucionar este problema deberemos hacer solo dos cosas:</p>
<ol>
<li>En nuestro <strong>config.php</strong> modificaremos el <em>$config['uri_protocolo'] </em>dejándolo similar a este:<br />
[code lang="php"]<br />
$config['uri_protocol'] = "PATH_INFO";<br />
[/code]</li>
<li>En nuestros controladores usaremos la siguiente función para reconstruir el array <strong>$_GET</strong>:<br />
[code lang="php"]<br />
parse_str($_SERVER['QUERY_STRING'],$_GET);<br />
[/code]</li>
</ol>
<p>Con esto, debería funcionar perfectamente. Pronto, más trucos, programas y ejemplos sobre <a href="http://www.codeigniter.com">CodeIgniter</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ipalaus.es/activar-get-en-codeigniter/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Consultas MySQL en CodeIgniter</title>
		<link>http://blog.ipalaus.es/consultas-mysql-en-codeigniter</link>
		<comments>http://blog.ipalaus.es/consultas-mysql-en-codeigniter#comments</comments>
		<pubDate>Mon, 17 Mar 2008 10:49:28 +0000</pubDate>
		<dc:creator>Isern Palaus</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[consultas mysql]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.ipalaus.es/consultas-mysql-en-codeigniter</guid>
		<description><![CDATA[Aunque pueda parecer difícil, hacer consultas en MySQL en CodeIgniter es la cosa más fácil del mundo. Y no solo con MySQL sino con todos los protocolos soportados por el framework.  Es importante, sobretodo, que tengamos nuestro CodeIgniter correctamente configurado. Podéis echarle una ojeada al artículo de configuración y iniciación para ver como configuramos <a href="http://blog.ipalaus.es/consultas-mysql-en-codeigniter" class="more-link">Más &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Aunque pueda parecer difícil, hacer consultas en <a href="http://www.mysql.org">MySQL</a> en <a href="http://www.codeigniter.com">CodeIgniter</a> es la cosa más fácil del mundo. Y no solo con MySQL sino con todos los protocolos soportados por el <em>framework</em>.  Es importante, sobretodo, que tengamos nuestro <a href="http://www.codeigniter.com">CodeIgniter</a> correctamente configurado. Podéis echarle una ojeada al artículo de <a href="http://blog.ipalaus.es/codeigniter-iniciacion-y-configuracion">configuración y iniciación</a> para ver como configuramos los datos de MySQL.</p>
<p><a href="http://www.codeigniter.com">CodeIgniter</a>, a parte, nos da la posibilidad de trabajar con más de una base de datos a la vez, configurando y conectando específicamente a una u otra dependiendo de las necesidades. Sin embargo, no es el objeto de esta explicación. </p>
<p>Supongamos que queremos hacer una consulta parecida a la siguiente:<br />
<code>SELECT * FROM entradas</code></p>
<p>Lo normal en PHP sería usar un <em>mysql_query(&#8220;SELECT * FROM entradas&#8221;);</em>, sin embargo en <a href="http://www.codeigniter.com">CodeIgniter</a> (y usando librería específica) lo usaríamos de la siguiente forma:<br />
[code lang="php"]<br />
$this->db->query("SELECT * FROM entradas");<br />
[/code]</p>
<h2>GET</h2>
<p>Conclusión, podemos usarlo de la misma manera. Luego si quisiéramos estructurar los resultados podríamos usar la función <a href="http://www.php.net/foreach"><em>foreach</em></a> de PHP. Sin embargo, hay una manera mucho más fácil en <a href="http://www.codeigniter.com">CodeIgniter</a> de tratar las consultas. Ellos lo llaman el <em>Active Record Class</em> y se emplearía, para el ejemplo de antes, así:<br />
[code lang="php"]<br />
$query = $this->db->get("entradas");</p>
<p>// Genera: SELECT * FROM entradas;<br />
[/code]</p>
<p>También en <em>$this->db->get();</em> es posible usar un segundo parámetro para especificar un <em>LIMIT</em>:<br />
[code lang="php"]<br />
$query = $this->db->get("entradas", 10, 20);</p>
<p>// Genera: SELECT * FROM entradas LIMIT 20,10<br />
[/code]</p>
<h2>SELECT</h2>
<p>También podemos especificar el SELECT con $this->db->select(); tipo:<br />
[code lang="php"]<br />
$query = $this->db->select("id,title,body");<br />
$query = $this->db->get("entradas");</p>
<p>// Genera: SELECT id,title,body FROM entradas<br />
[/code]</p>
<p>Existen algunas funciones de MySQL que tienen una propiedad de <em>SELECT</em> específica en <a href="http://www.codeigniter.com">CodeIgniter</a>, sin embargo, solo los listaré ya que no los usaremos en aplicaciones básicas:</p>
<ul>
<li><em>$this->db->select_max();</em></li>
<li><em>$this->db->select_min();</em></li>
<li><em>$this->db->select_avg();</em></li>
<li><em>$this->db->select_sum();</em></li>
</ul>
<h2>JOIN</h2>
<p>Esto nos permite unir dos tablas tal que así:<br />
[code lang="php"]<br />
$query = $this->db->join("comentarios", "comentarios.id = entradas.id");<br />
$query = $this->db->get("entradas");</p>
<p>// Genera: SELECT * FROM entradas JOIN comentarios ON comentarios.id = entradas.id<br />
[/code]</p>
<h2>WHERE</h2>
<p>[code lang="php"]<br />
$query = $this->db->where("id","38");<br />
$query = $this->db->get("entradas");</p>
<p>// Genera: SELECT * FROM entradas WHERE id = '38'<br />
[/code]</p>
<p>Si quisiéramos podríamos unir varios WHERE, simplemente añadiendo otras condiciones:<br />
[code lang="php"]<br />
$query = $this->db->where("id","38");<br />
$query = $this->db->where("name","Isern");<br />
$query = $this->db->where("surname","Palaus");<br />
$query = $this->db->get("entradas");</p>
<p>// Genera: SELECT * FROM entradas WHERE id = '38' AND name = 'Isern' AND surname = 'Palaus'<br />
[/code]</p>
<p>Pero claro, no todo son igualdades. Quizás queremos buscar una cosa que sea más pequeña que, o diferente, o mayor, etcétera. La forma es especificar en el primer campo, si no hay nada se tomará <em>=</em> por defecto:<br />
[code lang="php"]<br />
$query = $this->db->where("id >","38");<br />
$query = $this->db->where("name !=","Isern");<br />
$query = $this->db->where("surname","Palaus");<br />
$query = $this->db->get("entradas");</p>
<p>// Genera: SELECT * FROM entradas WHERE id > '38' AND name != 'Isern' AND surname = 'Palaus'<br />
[/code]</p>
<p>Al igual que <strong>SELECT</strong>, hay muchas más propiedades:</p>
<ul>
<li><em>$this->db->or_where();</em></li>
<li><em>$this->db->where_in();</em></li>
<li><em>$this->db->or_where_in();</em></li>
<li><em>$this->db->where_not_in();</em></li>
<li><em>$this->db->or_where_not_in();</em></li>
</ul>
<h2>LIKE</h2>
<p>[code lang="php"]<br />
$query = $this->db->like("body","sentencia");<br />
$query = $this->db->get("entradas");</p>
<p>// Genera: SELECT * FROM entras LIKE body = '%sentencia%'<br />
[/code]</p>
<p>Sin embargo, podría ser que no quisiéramos que las dos partes fueran aleatorias&#8230; De modo que podemos especificar en un tercer campo el <em>%</em> donde debe estar. Puede ser: <em>before</em>, <em>both</em> y <em>after</em>.<br />
[code lang="php"]<br />
$query = $this->db->like("body","sentencia1","before");<br />
$query = $this->db->like("title","sentencia2","both");<br />
$query = $this->db->like("slug","sentencia3","after");<br />
$query = $this->db->get("entradas");</p>
<p>// Genera: SELECT * FROM entradas LIKE body = '%sentencia1' AND title = '%sentencia2%' AND slug = 'sentencia3%'<br />
[/code]</p>
<p>Otros tipos de <b>LIKE</b> que podemos usar son:</p>
<ul>
<li><em>$this->db->not_like();</em></li>
<li><em>$this->db->or_not_like();</em></li>
<li><em>$this->db->group_by();</em></li>
</ul>
<h2>GROUP BY</h2>
<p>En otras versiones se conocia como <em>$this->db->groupby();</em> pero ha sido eliminado.<br />
[code lang="php"]<br />
$query = $this->db->group_by("title");<br />
$query = $this->db->get("entradas");</p>
<p>// Genera: SELECT * FROM entradas GROUP BY title<br />
[/code]</p>
<h2>DISTINCT</h2>
<p>Para añadir DISTINCT a la consulta:<br />
[code lang="php"]<br />
$query = $this->db->distinct();<br />
$query = $this->db->get("entradas");</p>
<p>// Genera: SELECT DISTINCT * FROM entradas<br />
[/code]</p>
<h2>HAVING</h2>
<p>[code lang="php"]<br />
$query = $this->db->having("uid = 32");<br />
$query = $this->db->get("entradas");</p>
<p>// Genera: SELECT * FROM entradas HAVING uid = 32<br />
[/code]</p>
<p>También es posible usar <em>$this->db->or_having();</em></p>
<h2>ORDER BY</h2>
<p><em>$this->db->order_by();</em> permite ordenar un resultado en una dirección especifica. En el primer parámetro especificamos el nombre de la columna y en el segundo la dirección. Las posibilidades del segundo parámetro son: <em>ASC</em>, <em>DESC</em> y <em>RANDOM</em>.<br />
[code lang="php"]<br />
$query = $this->db->order_by("id","DESC");<br />
$query = $this->db->get("entradas");</p>
<p>// Genera: SELECT * FROM entradas ORDER BYid DESC<br />
[/code]</p>
<h2>LIMIT</h2>
<p>Permite especificar el limite de resultados que quieres que devuelva:<br />
[code lang="php"]<br />
$query = $this->db->limit(30);<br />
$query = $this->db->get("entradas");</p>
<p>// Genera: SELECT * FROM entradas LIMIT 10<br />
[/code]</p>
<h2>COUNT ALL</h2>
<p>Permite contar el numero de entradas que hay en una tabla:<br />
[code lang="php"]<br />
$num = $this->db->count_all("entradas");</p>
<p>// Genera: un numero que lo podemos tratar como una variable o escribirlo<br />
[/code]</p>
<h2>COUNT ALL RESULTS</h2>
<p>A diferencia de <strong>COUNT ALL</strong>, nos permite contar el numero de resultados en la actual consulta:<br />
[code lang="php"]<br />
$query = $this->db->where("name","Isern");<br />
$query = $this->db->get("entradas");</p>
<p>$num = $this->db->count_all_results();</p>
<p>// Genera: un numero<br />
[/code]</p>
<h2>INSERT</h2>
<p>Para insertar datos usando el Active Record de <a href="http://www.codeigniter.com">CodeIgniter</a> debemos usar un array luego insertar:<br />
[code lang="php"]<br />
$insert = array("title" => "Test",<br />
                     "body" => "Test",<br />
                     "name" => "Isern",<br />
                     "surname" => "Palaus");</p>
<p>$this->db->insert("entradas",$insert);</p>
<p>// Genera: INSERT INTO entradas (title, body, name, surname) VALUES ('Test', 'Test', 'Isern', 'Palaus')<br />
[/code]</p>
<h2>UPDATE</h2>
<p>Al igual que <strong>INSERT</strong> usaremos un array para insertar, sin embargo si queremos actualizar, por ejemplo, una entrada deberemos especificar un where:<br />
[code lang="php"]<br />
$update = array("title" => "Test",<br />
                      "body" => "Test",<br />
                      "name" => "Isern",<br />
                      "surname" => "Palaus");</p>
<p>$this->db->where("id","3");<br />
$this->db->update("entradas",$update);</p>
<p>// Genera: UPDATE entradas SET title = 'Test', body = 'Test', name = 'Isern', surname = 'Palaus' WHERE id = 3<br />
[/code]</p>
<h2>DELETE</h2>
<p>Al igual que UPDATE usaremos un ID para especificar cual es la que queremos borrar:<br />
[code lang="php"]<br />
$this->db->where("id","3");<br />
$this->db->delete("entradas");</p>
<p>// Genera: DELETE FROM entradas WHERE id = 3<br />
[/code]</p>
<p>Y esto es más o menos todo lo que nos ofrece <a href="http://www.codeigniter.com">CodeIgniter</a> para tratar nuestras bases de datos. Espero que haya servido de ayuda a más de uno ya que muchas visitas recibidas buscaban como usar MySQL en <a href="http://www.codeigniter.com">CodeIgniter</a>.</h2>
]]></content:encoded>
			<wfw:commentRss>http://blog.ipalaus.es/consultas-mysql-en-codeigniter/feed</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>
